mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
WebClient WIP: add support for localizations
Signed-off-by: Nicola Murino <nicola.murino@gmail.com>
This commit is contained in:
@@ -532,22 +532,28 @@ func changeUserPassword(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
func doChangeUserPassword(r *http.Request, currentPassword, newPassword, confirmNewPassword string) error {
|
||||
if currentPassword == "" || newPassword == "" || confirmNewPassword == "" {
|
||||
return util.NewValidationError("please provide the current password and the new one two times")
|
||||
return util.NewI18nError(
|
||||
util.NewValidationError("please provide the current password and the new one two times"),
|
||||
util.I18nErrorChangePwdRequiredFields,
|
||||
)
|
||||
}
|
||||
if newPassword != confirmNewPassword {
|
||||
return util.NewValidationError("the two password fields do not match")
|
||||
return util.NewI18nError(util.NewValidationError("the two password fields do not match"), util.I18nErrorChangePwdNoMatch)
|
||||
}
|
||||
if currentPassword == newPassword {
|
||||
return util.NewValidationError("the new password must be different from the current one")
|
||||
return util.NewI18nError(
|
||||
util.NewValidationError("the new password must be different from the current one"),
|
||||
util.I18nErrorChangePwdNoDifferent,
|
||||
)
|
||||
}
|
||||
claims, err := getTokenClaims(r)
|
||||
if err != nil || claims.Username == "" {
|
||||
return errors.New("invalid token claims")
|
||||
return util.NewI18nError(errInvalidTokenClaims, util.I18nErrorInvalidToken)
|
||||
}
|
||||
_, err = dataprovider.CheckUserAndPass(claims.Username, currentPassword, util.GetIPFromRemoteAddress(r.RemoteAddr),
|
||||
getProtocolFromRequest(r))
|
||||
if err != nil {
|
||||
return util.NewValidationError("current password does not match")
|
||||
return util.NewI18nError(util.NewValidationError("current password does not match"), util.I18nErrorChangePwdCurrentNoMatch)
|
||||
}
|
||||
|
||||
return dataprovider.UpdateUserPassword(claims.Username, newPassword, dataprovider.ActionExecutorSelf,
|
||||
|
||||
Reference in New Issue
Block a user