diff --git a/back/models/vn-user.js b/back/models/vn-user.js index 47c7fd82d..45b70fc77 100644 --- a/back/models/vn-user.js +++ b/back/models/vn-user.js @@ -110,8 +110,9 @@ module.exports = function(Self) { const _setPassword = Self.setPassword; Self.setPassword = async function(id, newPassword, options, cb) { - // await Self.rawSql(`CALL account.user_setPassword(?, ?)`, - // [id, newPassword]); + await Self.rawSql(`CALL account.user_setPassword(?, ?)`, + [id, newPassword]); + console.log('Entry in override SET_PASSWORD'); await Self.app.models.Account.syncById(id, newPassword); await _setPassword.call(this, id, newPassword, options, cb); @@ -121,10 +122,11 @@ module.exports = function(Self) { }; const _changePassword = Self.changePassword; - Self.changePassword = async function(id, oldPassword, newPassword, options, cb) { - // await Self.rawSql(`CALL account.user_changePassword(?, ?, ?)`, - // [id, oldPassword, newPassword]); - await Self.app.models.Account.syncById(id, newPassword); + Self.changePassword = async function(id = 9, oldPassword, newPassword, options, cb) { + console.log(id, oldPassword, newPassword); + await Self.rawSql(`CALL account.user_changePassword(?, ?, ?)`, + [id, oldPassword, newPassword]); + console.log('Entry in override CHANGE_PASSWORD'); await _changePassword.call(this, id, oldPassword, newPassword, options, cb); return; }; diff --git a/back/models/vn-user.json b/back/models/vn-user.json index ce78b09a8..e23b7daa9 100644 --- a/back/models/vn-user.json +++ b/back/models/vn-user.json @@ -109,6 +109,13 @@ "principalType": "ROLE", "principalId": "$everyone", "permission": "ALLOW" + }, + { + "property": "changePassword", + "accessType": "EXECUTE", + "principalType": "ROLE", + "principalId": "$everyone", + "permission": "ALLOW" }, { "property": "validateToken", diff --git a/front/salix/components/change-password/index.js b/front/salix/components/change-password/index.js index 1ab9a8a62..a79e7a8a9 100644 --- a/front/salix/components/change-password/index.js +++ b/front/salix/components/change-password/index.js @@ -23,6 +23,7 @@ export default class Controller { submit() { const newPassword = this.newPassword; + const oldPassword = this.oldPassword; if (!newPassword) throw new UserError(`You must enter a new password`); @@ -30,12 +31,12 @@ export default class Controller { throw new UserError(`Passwords don't match`); const headers = { - Authorization: this.$location.$$search.access_token + Authorization: {principalType: 'VnUser'} }; - this.$http.post('VnUsers/change-password', {newPassword}, {headers}) + this.$http.post('VnUsers/change-password', {oldPassword, newPassword}, {headers}) .then(() => { - this.vnApp.showSuccess(this.$translate.instant('Password changed!')); + this.vnApp.showSuccess(this.$translate.instant('Password updated!')); this.$state.go('login'); }); } diff --git a/front/salix/components/change-password/locale/es.yml b/front/salix/components/change-password/locale/es.yml index 5a855e557..9898df702 100644 --- a/front/salix/components/change-password/locale/es.yml +++ b/front/salix/components/change-password/locale/es.yml @@ -2,7 +2,7 @@ Change password: Cambiar contraseña Old password: Antigua contraseña New password: Nueva contraseña Repeat password: Repetir contraseña -Password changed!: ¡Contraseña actualizada! +Password updated!: ¡Contraseña actualizada! Password requirements: > La contraseña debe tener al menos {{ length }} caracteres de longitud, {{nAlpha}} caracteres alfabéticos, {{nUpper}} letras mayúsculas, {{nDigits}} diff --git a/front/salix/components/login/index.js b/front/salix/components/login/index.js index d944983b7..c7edb2339 100644 --- a/front/salix/components/login/index.js +++ b/front/salix/components/login/index.js @@ -1,5 +1,6 @@ import ngModule from '../../module'; import './style.scss'; +import UserError from 'core/lib/user-error'; /** * A simple login form. @@ -27,11 +28,13 @@ export default class Controller { this.loading = false; this.password = ''; this.focusUser(); - console.log(req.data.error); - console.log(req.data.error.code); - throw req; - if (req.data.error.code = 'passExpired') + // console.log(req.data.error); + // console.log(req.data.error.code); + + if (req.data.error.code == 'passExpired') this.$state.go('change-password'); + + throw req; }); }