Skip to content

Commit

Permalink
fix: corrected verifyCode passing;
Browse files Browse the repository at this point in the history
  • Loading branch information
ncoonrod committed Jan 24, 2024
1 parent ecde79b commit 6e412ad
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@hotstaq/userroute",
"description": "A user route for HotStaq. Allows users to be created/edited/deleted securely.",
"version": "0.4.6",
"version": "0.4.7",
"main": "build/src/index.js",
"scripts": {
"test": "hotstaq --dev --env-file .env run --server-type api --api-test",
Expand Down
8 changes: 7 additions & 1 deletion src/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ export class User implements IUser
let result: any = await db.queryOne (
`INSERT INTO users (id, userType, displayName, firstName, lastName, email, password, passwordSalt, verifyCode, verified)
VALUES (UNHEX(REPLACE(UUID(),'-','')), ?, ?, ?, ?, ?, ?, ?, ?, ?) returning id;`,
[this.userType, this.displayName, this.firstName, this.lastName, this.email, hash, salt, verificationCode, verified]);
[this.userType, this.displayName, this.firstName, this.lastName, this.email, hash, salt, this.verifyCode, verified]);

if (result.error != null)
throw new Error (result.error);
Expand Down Expand Up @@ -640,6 +640,12 @@ export class User implements IUser
*/
static async changePassword (db: HotDBMySQL, user: User, newPassword: string): Promise<void>
{
if (newPassword === "")
throw new Error (`New password cannot be empty!`);

if (user.id === "")
throw new Error (`No user id supplied!`);

const salt: string = await User.generateSalt ();
const hash: string = await User.generateHash (newPassword, salt);

Expand Down
2 changes: 1 addition & 1 deletion src/UserRoute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ export class UserRoute extends HotRoute

await newUser.register (this.db, emailConfig, verifyCodeOverride);

req.passObject.passType = PassType.Update;
req.passObject.passType = PassType.Ignore;
req.passObject.jsonObj = { verifyCode: newUser.verifyCode, user: newUser };

newUser.verifyCode = "";
Expand Down

0 comments on commit 6e412ad

Please sign in to comment.