refs #5472 feat(out_login): change-password
gitea/salix/pipeline/head There was a failure building this commit Details

This commit is contained in:
Alex Moreno 2023-05-05 14:50:20 +02:00
parent 2da4289695
commit 728ef965c4
5 changed files with 27 additions and 14 deletions

View File

@ -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;
};

View File

@ -109,6 +109,13 @@
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"property": "changePassword",
"accessType": "EXECUTE",
"principalType": "ROLE",
"principalId": "$everyone",
"permission": "ALLOW"
},
{
"property": "validateToken",

View File

@ -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');
});
}

View File

@ -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}}

View File

@ -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;
});
}