From a35847f7b95345a5d31b73419eb7593fda2ba527 Mon Sep 17 00:00:00 2001 From: Javier Segarra Date: Sat, 27 Apr 2024 21:27:47 +0200 Subject: [PATCH] feat(salix): refs #6427 #6427 Update Request body --- front/salix/components/recover-password/index.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/front/salix/components/recover-password/index.js b/front/salix/components/recover-password/index.js index 7d18a326e2..8e88f2b4dd 100644 --- a/front/salix/components/recover-password/index.js +++ b/front/salix/components/recover-password/index.js @@ -12,6 +12,11 @@ export default class Controller { $state, $location }); + $scope.$watch('$ctrl.user', function(nuevoValor) { + let isPhone = /^[\d+]+$/ig.test(nuevoValor ?? ''); + // Evaluo si el valor introducido es un nĂºmero y se marca o desmarca el checkbox de revibir por sms + $scope.$ctrl.isPhone = isPhone; + }); } goToLogin() { @@ -21,10 +26,8 @@ export default class Controller { goToChangePassword({token}) { if (!token) this.vnApp.showError(this.$translate.instant('Invalid login')); - else { - this.$state.params.userId = this.userId; + else this.$location.path('/reset-password').search('access_token', token.id); - } } goToOTP(otp) { this.otp = true; @@ -33,11 +36,11 @@ export default class Controller { } submit() { - if (!this.user || (this.sms && !this.userId) || (this.otp && !this.code)) + if (!this.user || (this.sms) || (this.otp && !this.code)) throw new UserError(`Credentials not valid`); - if (this.sms || this.otp) { - this.$http.post('VnUsers/recoverPasswordSMS', {id: this.userId, phone: this.user, otp: this.code}) + if (this.isPhone || this.otp) { + this.$http.post('VnUsers/recoverPasswordSMS', {recoveryPhone: this.user, otp: this.code}) .then(({data}) => { data.otp && this.goToOTP(data.otp); data.token && this.goToChangePassword(data);