Allow deactivation of SSO users (#7952)
Этот коммит содержится в:
коммит произвёл
Christopher Speller
родитель
ae931ae6b6
Коммит
617a98d6d8
12
api4/user.go
12
api4/user.go
@@ -683,10 +683,18 @@ func updateUserActive(c *Context, w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
if ruser, err := c.App.UpdateNonSSOUserActive(c.Params.UserId, active); err != nil {
|
||||
var user *model.User
|
||||
var err *model.AppError
|
||||
|
||||
if user, err = c.App.GetUser(c.Params.UserId); err != nil {
|
||||
c.Err = err
|
||||
return
|
||||
}
|
||||
|
||||
if _, err := c.App.UpdateActive(user, active); err != nil {
|
||||
c.Err = err
|
||||
} else {
|
||||
c.LogAuditWithUserId(ruser.Id, fmt.Sprintf("active=%v", active))
|
||||
c.LogAuditWithUserId(user.Id, fmt.Sprintf("active=%v", active))
|
||||
ReturnStatusOK(w)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1163,6 +1163,13 @@ func TestUpdateUserActive(t *testing.T) {
|
||||
|
||||
_, resp = SystemAdminClient.UpdateUserActive(user.Id, false)
|
||||
CheckNoError(t, resp)
|
||||
|
||||
authData := model.NewId()
|
||||
result := <-th.App.Srv.Store.User().UpdateAuthData(user.Id, "random", &authData, "", true)
|
||||
require.Nil(t, result.Err)
|
||||
|
||||
_, resp = SystemAdminClient.UpdateUserActive(user.Id, false)
|
||||
CheckNoError(t, resp)
|
||||
}
|
||||
|
||||
func TestGetUsers(t *testing.T) {
|
||||
@@ -2123,7 +2130,9 @@ func TestSwitchAccount(t *testing.T) {
|
||||
defer func() {
|
||||
utils.SetIsLicensed(isLicensed)
|
||||
utils.SetLicense(license)
|
||||
th.App.UpdateConfig(func(cfg *model.Config) { *cfg.ServiceSettings.ExperimentalEnableAuthenticationTransfer = enableAuthenticationTransfer })
|
||||
th.App.UpdateConfig(func(cfg *model.Config) {
|
||||
*cfg.ServiceSettings.ExperimentalEnableAuthenticationTransfer = enableAuthenticationTransfer
|
||||
})
|
||||
}()
|
||||
utils.SetIsLicensed(true)
|
||||
utils.SetLicense(&model.License{Features: &model.Features{}})
|
||||
|
||||
@@ -184,8 +184,8 @@ func changeUserActiveStatus(a *app.App, user *model.User, userArg string, activa
|
||||
if user == nil {
|
||||
return fmt.Errorf("Can't find user '%v'", userArg)
|
||||
}
|
||||
if user.IsLDAPUser() {
|
||||
return errors.New("You can not modify the activation status of AD/LDAP accounts. Please modify through the AD/LDAP server.")
|
||||
if user.IsSSOUser() {
|
||||
fmt.Println("You must also deactivate this user in the SSO provider or they will be reactivated on next login or sync.")
|
||||
}
|
||||
if _, err := a.UpdateActive(user, activate); err != nil {
|
||||
return fmt.Errorf("Unable to change activation status of user: %v", userArg)
|
||||
|
||||
Ссылка в новой задаче
Block a user