[AI assisted] MM-62837: (#30268)
We did not invalidate the cache after converting a user to bot. That led to issues. See JIRA for more details. https://mattermost.atlassian.net/browse/MM-62837 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
102e3472d8
Коммит
fd356b62b4
@@ -6601,6 +6601,25 @@ func TestConvertUserToBot(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.NotNil(t, bot)
|
require.NotNil(t, bot)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
t.Run("user cannot login after being converted to bot", func(t *testing.T) {
|
||||||
|
// Create a new user
|
||||||
|
user := th.CreateUser()
|
||||||
|
|
||||||
|
// Login as the new user to verify login works initially
|
||||||
|
_, _, err := th.Client.Login(context.Background(), user.Email, user.Password)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Convert user to bot
|
||||||
|
_, _, err = th.SystemAdminClient.ConvertUserToBot(context.Background(), user.Id)
|
||||||
|
require.NoError(t, err)
|
||||||
|
|
||||||
|
// Try to login again - should fail
|
||||||
|
_, resp, err := th.Client.Login(context.Background(), user.Email, user.Password)
|
||||||
|
require.Error(t, err)
|
||||||
|
CheckErrorID(t, err, "api.user.login.bot_login_forbidden.app_error")
|
||||||
|
CheckUnauthorizedStatus(t, resp)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestGetChannelMembersWithTeamData(t *testing.T) {
|
func TestGetChannelMembersWithTeamData(t *testing.T) {
|
||||||
|
|||||||
@@ -617,6 +617,7 @@ func (a *App) ConvertUserToBot(rctx request.CTX, user *model.User) (*model.Bot,
|
|||||||
if err := a.RevokeAllSessions(rctx, user.Id); err != nil {
|
if err := a.RevokeAllSessions(rctx, user.Id); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
a.InvalidateCacheForUser(user.Id)
|
||||||
|
|
||||||
return bot, nil
|
return bot, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user