MM-29607 allow user to deactivate MFA even when disabled (#16994)

Automatic Merge
Этот коммит содержится в:
Max Erenberg
2021-03-22 14:32:19 -04:00
коммит произвёл GitHub
родитель 6a77e24adc
Коммит 0aa6499a48
2 изменённых файлов: 15 добавлений и 4 удалений

Просмотреть файл

@@ -781,10 +781,6 @@ func (a *App) ActivateMfa(userID, token string) *model.AppError {
}
func (a *App) DeactivateMfa(userID string) *model.AppError {
if !*a.Config().ServiceSettings.EnableMultifactorAuthentication {
return model.NewAppError("DeactivateMfa", "mfa.mfa_disabled.app_error", nil, "", http.StatusNotImplemented)
}
if err := mfa.New(a.Srv().Store.User()).Deactivate(userID); err != nil {
return model.NewAppError("DeactivateMfa", "mfa.deactivate.app_error", nil, err.Error(), http.StatusInternalServerError)
}

Просмотреть файл

@@ -1440,3 +1440,18 @@ func TestUpdateUserRolesWithUser(t *testing.T) {
_, err = th.App.UpdateUserRolesWithUser(user, "does not exist", false)
require.NotNil(t, err)
}
func TestDeactivateMfa(t *testing.T) {
t.Run("MFA is disabled", func(t *testing.T) {
th := Setup(t).InitBasic()
defer th.TearDown()
th.App.UpdateConfig(func(cfg *model.Config) {
*cfg.ServiceSettings.EnableMultifactorAuthentication = false
})
user := th.BasicUser
err := th.App.DeactivateMfa(user.Id)
require.Nil(t, err)
})
}