1
0
Fork 0
mirror of https://github.com/mmumshad/ansible-playable.git synced 2025-02-15 04:42:05 +00:00
ansible-playable/client/app/account/settings/settings.controller.js
Mumshad Mannambeth c92f737237 Initial Commit
2017-06-07 13:36:45 -04:00

36 lines
711 B
JavaScript

'use strict';
export default class SettingsController {
user = {
oldPassword: '',
newPassword: '',
confirmPassword: ''
};
errors = {
other: undefined
};
message = '';
submitted = false;
/*@ngInject*/
constructor(Auth) {
this.Auth = Auth;
}
changePassword(form) {
this.submitted = true;
if(form.$valid) {
this.Auth.changePassword(this.user.oldPassword, this.user.newPassword)
.then(() => {
this.message = 'Password successfully changed.';
})
.catch(() => {
form.password.$setValidity('mongoose', false);
this.errors.other = 'Incorrect password';
this.message = '';
});
}
}
}