refs #6427 feat: front updates

This commit is contained in:
Javier Segarra 2024-03-26 08:20:04 +01:00
parent 2ae298cd9e
commit b7f39b45ab
1 changed files with 4 additions and 10 deletions

View File

@ -18,19 +18,13 @@ export default class Controller {
$scope.$ctrl.sms = isSms; $scope.$ctrl.sms = isSms;
}); });
} }
// ONLY FOR TESTS
// $onInit() {
// this.$scope.$ctrl.sms = true;
// this.$scope.$ctrl.userId = '9';
// this.$scope.$ctrl.user = '432978106';
// }
goToLogin() { goToLogin() {
this.vnApp.showSuccess(this.$translate.instant('Notification sent!')); this.vnApp.showSuccess(this.$translate.instant('Notification sent!'));
this.$state.go('login'); this.$state.go('login');
} }
goToChangePassword({valid: isValid, token}) { goToChangePassword({token}) {
if (!isValid) if (!token)
this.vnApp.showError(this.$translate.instant('Invalid login')); this.vnApp.showError(this.$translate.instant('Invalid login'));
else { else {
this.$state.params.userId = this.userId; this.$state.params.userId = this.userId;
@ -40,7 +34,7 @@ export default class Controller {
goToOTP(otp) { goToOTP(otp) {
this.otp = true; this.otp = true;
this.$state.params.otp = otp; this.$state.params.otp = otp;
this.code = otp; this.code = null;
} }
submit() { submit() {
@ -51,7 +45,7 @@ export default class Controller {
this.$http.post('VnUsers/recoverPasswordSMS', {id: this.userId, phone: this.user, otp: this.code}) this.$http.post('VnUsers/recoverPasswordSMS', {id: this.userId, phone: this.user, otp: this.code})
.then(({data}) => { .then(({data}) => {
data.otp && this.goToOTP(data.otp); data.otp && this.goToOTP(data.otp);
data.valid && this.goToChangePassword(data); data.token && this.goToChangePassword(data);
}); });
} else { } else {
this.$http.post('VnUsers/recoverPassword', {user: this.user}) this.$http.post('VnUsers/recoverPassword', {user: this.user})