MCPcopy
hub / github.com/gotify/server / ChangePassword

Method ChangePassword

api/user.go:363–373  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

361// schema:
362// $ref: "#/definitions/Error"
363func (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

Callers 2

Test_UpdatePasswordMethod · 0.80

Calls 5

GetUserIDFunction · 0.92
CreatePasswordFunction · 0.92
successOrAbortFunction · 0.85
GetUserByIDMethod · 0.65
UpdateUserMethod · 0.65

Tested by 2

Test_UpdatePasswordMethod · 0.64