feat(salix): refs #6427 #6427 Update Request body

This commit is contained in:
Javier Segarra 2024-04-27 21:27:47 +02:00
parent 741ccf411e
commit a35847f7b9
1 changed files with 9 additions and 6 deletions

View File

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