From ee1b901dea69bcb30e972023e07b1e1e405a288c Mon Sep 17 00:00:00 2001 From: alexm Date: Fri, 16 Jun 2023 14:31:14 +0200 Subject: [PATCH] refs #5475 feat(account_changePassword): accessScope --- back/methods/vn-user/sign-in.js | 5 +++-- front/salix/components/change-password/index.js | 3 ++- modules/account/back/methods/account/change-password.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/back/methods/vn-user/sign-in.js b/back/methods/vn-user/sign-in.js index 9963719c3..f27d40e0a 100644 --- a/back/methods/vn-user/sign-in.js +++ b/back/methods/vn-user/sign-in.js @@ -61,11 +61,12 @@ module.exports = Self => { if (vnUser.passExpired && vnUser.passExpired.getTime() <= today.getTime()) { const $ = Self.app.models; const changePasswordToken = await $.AccessToken.create({ - scopes: ['change-password'], + scopes: ['changePassword'], userId: vnUser.id }); const err = new UserError('Pass expired', 'passExpired'); - err.details = {token: changePasswordToken, twoFactor: vnUser.twoFactor ? true : false}; + changePasswordToken.twoFactor = vnUser.twoFactor ? true : false; + err.details = {token: changePasswordToken}; throw err; } }; diff --git a/front/salix/components/change-password/index.js b/front/salix/components/change-password/index.js index 3c300ba4b..81a44d9d5 100644 --- a/front/salix/components/change-password/index.js +++ b/front/salix/components/change-password/index.js @@ -19,6 +19,7 @@ export default class Controller { this.repeatPassword = 'test.1234'; this.newPassword = 'test.1234'; this.verificationCode = '1234'; + console.log(this.$state.params); if (!this.$state.params.id) this.$state.go('login'); @@ -46,7 +47,7 @@ export default class Controller { Authorization: this.$state.params.id }; console.log({ - id, + id: userId, oldPassword, newPassword, verificationCode diff --git a/modules/account/back/methods/account/change-password.js b/modules/account/back/methods/account/change-password.js index 794195947..9fbb5dd17 100644 --- a/modules/account/back/methods/account/change-password.js +++ b/modules/account/back/methods/account/change-password.js @@ -3,7 +3,7 @@ module.exports = Self => { Self.remoteMethodCtx('changePassword', { description: 'Changes the user password', accessType: 'WRITE', - accessScopes: 'change-password', + accessScopes: ['changePassword'], accepts: [ { arg: 'oldPassword',