mirror of
https://gitlab.com/comunic/comunicapiv2
synced 2025-06-20 00:25:17 +00:00
Can change user password
This commit is contained in:
@ -232,6 +232,24 @@ export class AccountHelper {
|
||||
return token;
|
||||
}
|
||||
|
||||
/**
|
||||
* Destroy password reset token for a given user
|
||||
*
|
||||
* @param userID Target user ID
|
||||
*/
|
||||
public static async DestroyPasswordResetTokenForUser(userID: number) {
|
||||
await DatabaseHelper.UpdateRows({
|
||||
table: USER_TABLE,
|
||||
where: {
|
||||
ID: userID
|
||||
},
|
||||
set: {
|
||||
password_reset_token: "",
|
||||
password_reset_token_time_create: 85 // Value too low to be valid
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the ID of a user from a password reset token
|
||||
*
|
||||
@ -254,6 +272,23 @@ export class AccountHelper {
|
||||
return -1;
|
||||
|
||||
return result.ID;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the password of the user
|
||||
*
|
||||
* @param userID Target user ID
|
||||
* @param password Target password
|
||||
*/
|
||||
public static async ChangePassword(userID: number, password: string) {
|
||||
await DatabaseHelper.UpdateRows({
|
||||
table: USER_TABLE,
|
||||
where: {
|
||||
ID: userID
|
||||
},
|
||||
set: {
|
||||
password: this.CryptPassword(password)
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user