ChangePassword changes the password from the current user swagger:operation POST /current/user/password user updateCurrentUser Update the password of the current user. --- consumes: [application/json] produces: [application/json] security: [clientTokenAuthorizationHeader: [], clientTokenHeader
(ctx *gin.Context)
| 361 | // schema: |
| 362 | // $ref: "#/definitions/Error" |
| 363 | func (a *UserAPI) ChangePassword(ctx *gin.Context) { |
| 364 | pw := model.UserExternalPass{} |
| 365 | if err := ctx.Bind(&pw); err == nil { |
| 366 | user, err := a.DB.GetUserByID(auth.GetUserID(ctx)) |
| 367 | if success := successOrAbort(ctx, 500, err); !success { |
| 368 | return |
| 369 | } |
| 370 | user.Pass = password.CreatePassword(pw.Pass, a.PasswordStrength) |
| 371 | successOrAbort(ctx, 500, a.DB.UpdateUser(user)) |
| 372 | } |
| 373 | } |
| 374 | |
| 375 | // UpdateUserByID updates and user by id |
| 376 | // swagger:operation POST /user/{id} user updateUser |