blob: ca500dc01b7c83639912a5ebb79324a8569e6c33 [file] [log] [blame]
Matteo Scandolo035c5932016-12-14 09:55:15 -08001import {AuthService} from '../../datasources/rest/auth.rest';
Matteo Scandolof6acdbe2016-12-13 10:29:37 -08002
3class LoginCtrl {
4 static $inject = ['AuthService', '$state'];
5
6 /** @ngInject */
7 constructor(
8 private authService: AuthService,
9 private $state: angular.ui.IStateService
10 ) {
11 }
12
13 public login(username: string, password: string) {
Matteo Scandolo266907e2016-12-20 13:41:42 -080014 console.log(username, password);
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080015 this.authService.login({
16 username: username,
17 password: password
18 })
19 .then(res => {
Matteo Scandolo9f87f302016-12-13 18:11:10 -080020 this.$state.go('xos.dashboard');
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080021 })
22 .catch(e => console.error);
23 }
24}
25
26export const xosLogin: angular.IComponentOptions = {
27 template: require('./login.html'),
28 controllerAs: 'vm',
29 controller: LoginCtrl
30};