parent
741ccf411e
commit
a35847f7b9
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue