summaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2017-02-07 09:35:58 -0800
committerGitHub <noreply@github.com>2017-02-07 09:35:58 -0800
commit9dc76c18231f158ab71dfcfae2f1659a4f2a5396 (patch)
tree57a46a30e52e9f955f4d74d93fc6153640fbecc2 /app
parentba18374bd1b2644e577247204fad17dd52913b9b (diff)
downloadchat-9dc76c18231f158ab71dfcfae2f1659a4f2a5396.tar.gz
chat-9dc76c18231f158ab71dfcfae2f1659a4f2a5396.tar.bz2
chat-9dc76c18231f158ab71dfcfae2f1659a4f2a5396.zip
Implement PUT /users/{user_id}/password endpoint for APIv4 (#5243)
Diffstat (limited to 'app')
-rw-r--r--app/authentication.go8
-rw-r--r--app/user.go9
2 files changed, 7 insertions, 10 deletions
diff --git a/app/authentication.go b/app/authentication.go
index 0561ff821..3691c7c3e 100644
--- a/app/authentication.go
+++ b/app/authentication.go
@@ -4,12 +4,12 @@
package app
import (
+ "net/http"
+ "strings"
+
"github.com/mattermost/platform/einterfaces"
"github.com/mattermost/platform/model"
"github.com/mattermost/platform/utils"
-
- "net/http"
- "strings"
)
func CheckPasswordAndAllCriteria(user *model.User, password string, mfaToken string) *model.AppError {
@@ -123,7 +123,7 @@ func CheckUserMfa(user *model.User, token string) *model.AppError {
func checkUserLoginAttempts(user *model.User) *model.AppError {
if user.FailedAttempts >= utils.Cfg.ServiceSettings.MaximumLoginAttempts {
- return model.NewLocAppError("checkUserLoginAttempts", "api.user.check_user_login_attempts.too_many.app_error", nil, "user_id="+user.Id)
+ return model.NewAppError("checkUserLoginAttempts", "api.user.check_user_login_attempts.too_many.app_error", nil, "user_id="+user.Id, http.StatusForbidden)
}
return nil
diff --git a/app/user.go b/app/user.go
index c302db511..2fc308421 100644
--- a/app/user.go
+++ b/app/user.go
@@ -764,22 +764,19 @@ func UpdatePasswordAsUser(userId, currentPassword, newPassword, siteURL string)
}
if user == nil {
- err = model.NewLocAppError("updatePassword", "api.user.update_password.valid_account.app_error", nil, "")
- err.StatusCode = http.StatusBadRequest
+ err = model.NewAppError("updatePassword", "api.user.update_password.valid_account.app_error", nil, "", http.StatusBadRequest)
return err
}
if user.AuthData != nil && *user.AuthData != "" {
- err = model.NewLocAppError("updatePassword", "api.user.update_password.oauth.app_error", nil, "auth_service="+user.AuthService)
- err.StatusCode = http.StatusBadRequest
+ err = model.NewAppError("updatePassword", "api.user.update_password.oauth.app_error", nil, "auth_service="+user.AuthService, http.StatusBadRequest)
return err
}
if err := doubleCheckPassword(user, currentPassword); err != nil {
if err.Id == "api.user.check_user_password.invalid.app_error" {
- err = model.NewLocAppError("updatePassword", "api.user.update_password.incorrect.app_error", nil, "")
+ err = model.NewAppError("updatePassword", "api.user.update_password.incorrect.app_error", nil, "", http.StatusBadRequest)
}
- err.StatusCode = http.StatusForbidden
return err
}