Skip to content

Commit

Permalink
Feat: Send new token on changePassword
Browse files Browse the repository at this point in the history
  • Loading branch information
chakflying committed Dec 12, 2023
1 parent d7b3f69 commit e23d203
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
10 changes: 8 additions & 2 deletions server/model/user.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,14 @@ class User extends BeanModel {
* @returns {Promise<void>}
*/
async resetPassword(newPassword) {
await User.resetPassword(this.id, newPassword);
this.password = newPassword;
const hashedPassword = passwordHash.generate(newPassword);

await R.exec("UPDATE `user` SET password = ? WHERE id = ? ", [
hashedPassword,
this.id
]);

this.password = hashedPassword;
}

/**
Expand Down
1 change: 1 addition & 0 deletions server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,7 @@ let needSetup = false;

callback({
ok: true,
token: User.createJWT(user, server.jwtSecret),
msg: "successAuthChangePassword",
msgi18n: true,
});
Expand Down
4 changes: 4 additions & 0 deletions src/components/settings/Security.vue
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,10 @@ export default {
this.password.currentPassword = "";
this.password.newPassword = "";
this.password.repeatNewPassword = "";
// Update token of the current session
this.$root.storage().token = res.token;
this.$root.socket.token = res.token;
}
});
}
Expand Down

0 comments on commit e23d203

Please sign in to comment.