mirror of
https://github.com/mmumshad/ansible-playable.git
synced 2025-03-09 23:38:54 +00:00
38 lines
644 B
JavaScript
38 lines
644 B
JavaScript
'use strict';
|
|
|
|
export default class LoginController {
|
|
user = {
|
|
name: '',
|
|
email: '',
|
|
password: ''
|
|
};
|
|
errors = {
|
|
login: undefined
|
|
};
|
|
submitted = false;
|
|
|
|
|
|
/*@ngInject*/
|
|
constructor(Auth, $state) {
|
|
this.Auth = Auth;
|
|
this.$state = $state;
|
|
}
|
|
|
|
login(form) {
|
|
this.submitted = true;
|
|
|
|
if(form.$valid) {
|
|
this.Auth.login({
|
|
email: this.user.email,
|
|
password: this.user.password
|
|
})
|
|
.then(() => {
|
|
// Logged in, redirect to home
|
|
this.$state.go('main');
|
|
})
|
|
.catch(err => {
|
|
this.errors.login = err.message;
|
|
});
|
|
}
|
|
}
|
|
}
|