diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index aa7af45..323897a 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -95,6 +95,8 @@ export const Routes : Route[] = [ {path: "/settings/set_security", cb: (h) => SettingsController.SetSecurity(h)}, + {path: "/settings/update_password", cb: (h) => SettingsController.UpdatePassword(h)}, + // Friends controller {path: "/friends/getList", cb: (h) => FriendsController.GetList(h)}, diff --git a/src/controllers/SettingsController.ts b/src/controllers/SettingsController.ts index a72f1d9..ad52ba7 100644 --- a/src/controllers/SettingsController.ts +++ b/src/controllers/SettingsController.ts @@ -175,4 +175,19 @@ export class SettingsController { h.success(); } + + /** + * Update user password + * + * @param h Request handler + */ + public static async UpdatePassword(h: RequestHandler) { + await h.needUserPostPassword("oldPassword"); + + const newPassword = h.postString("newPassword"); + + await AccountHelper.ChangePassword(h.getUserId(), newPassword); + + h.success(); + } } \ No newline at end of file