perf(salix): refs #6427 CLEAN CODE
This commit is contained in:
parent
1d04ca1c8a
commit
5bdbb1f2ee
|
@ -31,10 +31,23 @@ export default class Controller {
|
|||
methodsAvailables() {
|
||||
return {
|
||||
'email': {
|
||||
url: 'VnUsers/recoverPassword', data: {user: this.user}
|
||||
url: 'VnUsers/recoverPassword',
|
||||
data: {user: this.user},
|
||||
cb: data => {
|
||||
if (data === '') this.goToLogin();
|
||||
}
|
||||
},
|
||||
'sms': {
|
||||
url: 'VnUsers/recoverPasswordSMS', data: {userId: this.user, verificationCode: this.verificationCode}
|
||||
url: 'VnUsers/recoverPasswordSMS',
|
||||
data: {userId: this.user, verificationCode: this.verificationCode},
|
||||
cb: data => {
|
||||
if (this.method && this.code) {
|
||||
data.token && this.goToChangePassword(data);
|
||||
!data.token && this.goToLogin();
|
||||
} else
|
||||
|
||||
data.code && this.handleCode(data.code);
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
|
@ -44,15 +57,7 @@ export default class Controller {
|
|||
throw new UserError(`Credentials not valid`);
|
||||
const method = this.methodsAvailables()[this.method];
|
||||
this.$http.post(method.url, method.data)
|
||||
.then(({data}) => {
|
||||
if (this.method && this.code) {
|
||||
data.token && this.goToChangePassword(data);
|
||||
!data.token && this.goToLogin();
|
||||
} else {
|
||||
if (data === '') this.goToLogin();
|
||||
data.code && this.handleCode(data.code);
|
||||
}
|
||||
});
|
||||
.then(({data}) => method.cb(data));
|
||||
}
|
||||
}
|
||||
Controller.$inject = ['$scope', '$element', '$http', 'vnApp', '$translate', '$state', '$location'];
|
||||
|
|
Loading…
Reference in New Issue