(c *context.Context, f form.ChangePassword)
| 196 | } |
| 197 | |
| 198 | func SettingsPasswordPost(c *context.Context, f form.ChangePassword) { |
| 199 | c.Title("settings.password") |
| 200 | c.PageIs("SettingsPassword") |
| 201 | |
| 202 | if c.HasError() { |
| 203 | c.HTML(http.StatusBadRequest, tmplUserSettingsPassword) |
| 204 | return |
| 205 | } |
| 206 | |
| 207 | if !userutil.ValidatePassword(c.User.Password, c.User.Salt, f.OldPassword) { |
| 208 | c.Flash.Error(c.Tr("settings.password_incorrect")) |
| 209 | } else if f.Password != f.Retype { |
| 210 | c.Flash.Error(c.Tr("form.password_not_match")) |
| 211 | } else { |
| 212 | err := database.Handle.Users().Update( |
| 213 | c.Req.Context(), |
| 214 | c.User.ID, |
| 215 | database.UpdateUserOptions{ |
| 216 | Password: &f.Password, |
| 217 | }, |
| 218 | ) |
| 219 | if err != nil { |
| 220 | c.Errorf(err, "update user") |
| 221 | return |
| 222 | } |
| 223 | c.Flash.Success(c.Tr("settings.change_password_success")) |
| 224 | } |
| 225 | |
| 226 | c.RedirectSubpath("/user/settings/password") |
| 227 | } |
| 228 | |
| 229 | func SettingsEmails(c *context.Context) { |
| 230 | c.Title("settings.emails") |
nothing calls this directly
no test coverage detected