Skip to content

Commit bcd7a4c

Browse files
[AI assisted] MM-62837: (#30268) (#30286)
Automatic Merge
1 parent db85b24 commit bcd7a4c

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

server/channels/api4/user_test.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6601,6 +6601,25 @@ func TestConvertUserToBot(t *testing.T) {
66016601
require.NoError(t, err)
66026602
require.NotNil(t, bot)
66036603
})
6604+
6605+
t.Run("user cannot login after being converted to bot", func(t *testing.T) {
6606+
// Create a new user
6607+
user := th.CreateUser()
6608+
6609+
// Login as the new user to verify login works initially
6610+
_, _, err := th.Client.Login(context.Background(), user.Email, user.Password)
6611+
require.NoError(t, err)
6612+
6613+
// Convert user to bot
6614+
_, _, err = th.SystemAdminClient.ConvertUserToBot(context.Background(), user.Id)
6615+
require.NoError(t, err)
6616+
6617+
// Try to login again - should fail
6618+
_, resp, err := th.Client.Login(context.Background(), user.Email, user.Password)
6619+
require.Error(t, err)
6620+
CheckErrorID(t, err, "api.user.login.bot_login_forbidden.app_error")
6621+
CheckUnauthorizedStatus(t, resp)
6622+
})
66046623
}
66056624

66066625
func TestGetChannelMembersWithTeamData(t *testing.T) {

server/channels/app/bot.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -617,6 +617,7 @@ func (a *App) ConvertUserToBot(rctx request.CTX, user *model.User) (*model.Bot,
617617
if err := a.RevokeAllSessions(rctx, user.Id); err != nil {
618618
return nil, err
619619
}
620+
a.InvalidateCacheForUser(user.Id)
620621

621622
return bot, nil
622623
}

0 commit comments

Comments
 (0)