diff options
Diffstat (limited to 'api4')
-rw-r--r-- | api4/context.go | 8 | ||||
-rw-r--r-- | api4/user.go | 4 |
2 files changed, 8 insertions, 4 deletions
diff --git a/api4/context.go b/api4/context.go index 32db0ed7d..37af2c6d4 100644 --- a/api4/context.go +++ b/api4/context.go @@ -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 } } diff --git a/api4/user.go b/api4/user.go index 1436808cd..d06dd2882 100644 --- a/api4/user.go +++ b/api4/user.go @@ -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") |