mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-07-12 21:02:48 +00:00
Can change user password
This commit is contained in:
src
@ -152,10 +152,29 @@ export class AccountController {
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async CheckPasswordResetToken(h: RequestHandler) {
|
||||
// We just get user ID to check the validity of the token
|
||||
await this.GetUserIDFromPasswordResetToken(h, "token");
|
||||
h.success("The token is valid.");
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset user password
|
||||
*
|
||||
* @param h Request handler
|
||||
*/
|
||||
public static async ResetUserPassword(h: RequestHandler) {
|
||||
const userID = await this.GetUserIDFromPasswordResetToken(h, "token");
|
||||
const newPassword = h.postString("password", 3);
|
||||
|
||||
// Set new password
|
||||
await AccountHelper.ChangePassword(userID, newPassword);
|
||||
|
||||
// Destroy reset token
|
||||
await AccountHelper.DestroyPasswordResetTokenForUser(userID);
|
||||
|
||||
h.success("Password changed!");
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the user ID associated to a password reset token
|
||||
*
|
||||
|
@ -53,6 +53,8 @@ export const Routes : Route[] = [
|
||||
|
||||
{path: "/account/check_password_reset_token", cb: (h) => AccountController.CheckPasswordResetToken(h), needLogin: false},
|
||||
|
||||
{path: "/account/reset_user_passwd", cb: (h) => AccountController.ResetUserPassword(h), needLogin: false},
|
||||
|
||||
|
||||
// User controller
|
||||
{path: "/user/getInfo", cb: (h) => UserController.GetSingle(h), needLogin: false},
|
||||
|
Reference in New Issue
Block a user