MM-32471: Use created user to update roles (#16895)
During user creation via CLI, we would create the user, but pass the user ID instead when updating the roles. This falls into the category of read-after-write within a single request. We fix this by passing the already created user and directly update the roles. https://mattermost.atlassian.net/browse/MM-32471 ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
1e3b6b56a6
Коммит
d8b94836cf
@@ -1547,6 +1547,11 @@ func (a *App) UpdateUserRoles(userID string, newRoles string, sendWebSocketEvent
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return a.UpdateUserRolesWithUser(user, newRoles, sendWebSocketEvent)
|
||||
}
|
||||
|
||||
func (a *App) UpdateUserRolesWithUser(user *model.User, newRoles string, sendWebSocketEvent bool) (*model.User, *model.AppError) {
|
||||
|
||||
if err := a.CheckRolesExist(strings.Fields(newRoles)); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -1586,7 +1591,7 @@ func (a *App) UpdateUserRoles(userID string, newRoles string, sendWebSocketEvent
|
||||
mlog.Warn("Failed during updating user roles", mlog.Err(result.NErr))
|
||||
}
|
||||
|
||||
a.InvalidateCacheForUser(userID)
|
||||
a.InvalidateCacheForUser(user.Id)
|
||||
a.ClearSessionCacheForUser(user.Id)
|
||||
|
||||
if sendWebSocketEvent {
|
||||
|
||||
Ссылка в новой задаче
Block a user