Fix MFA enforcement on login and page load (#6356)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
fb4d72bd8a
Коммит
202c383d8d
@@ -271,9 +271,13 @@ func (c *Context) MfaRequired() {
|
||||
return
|
||||
}
|
||||
|
||||
// Special case to let user get themself
|
||||
if c.Path == "/api/v4/users/me" {
|
||||
return
|
||||
}
|
||||
|
||||
if !user.MfaActive {
|
||||
c.Err = model.NewLocAppError("", "api.context.mfa_required.app_error", nil, "MfaRequired")
|
||||
c.Err.StatusCode = http.StatusUnauthorized
|
||||
c.Err = model.NewAppError("", "api.context.mfa_required.app_error", nil, "MfaRequired", http.StatusForbidden)
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,8 @@ func InitUser() {
|
||||
BaseRoutes.Users.Handle("/email/verify/send", ApiHandler(sendVerificationEmail)).Methods("POST")
|
||||
|
||||
BaseRoutes.Users.Handle("/mfa", ApiHandler(checkUserMfa)).Methods("POST")
|
||||
BaseRoutes.User.Handle("/mfa", ApiSessionRequired(updateUserMfa)).Methods("PUT")
|
||||
BaseRoutes.User.Handle("/mfa/generate", ApiSessionRequired(generateMfaSecret)).Methods("POST")
|
||||
BaseRoutes.User.Handle("/mfa", ApiSessionRequiredMfa(updateUserMfa)).Methods("PUT")
|
||||
BaseRoutes.User.Handle("/mfa/generate", ApiSessionRequiredMfa(generateMfaSecret)).Methods("POST")
|
||||
|
||||
BaseRoutes.Users.Handle("/login", ApiHandler(login)).Methods("POST")
|
||||
BaseRoutes.Users.Handle("/login/switch", ApiHandler(switchAccountType)).Methods("POST")
|
||||
|
||||
Ссылка в новой задаче
Block a user