blob: e5881ddb2b5840f920795bdf6366355ace44ca1f [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) {
14 this.authService.login({
15 username: username,
16 password: password
17 })
18 .then(res => {
Matteo Scandolo9f87f302016-12-13 18:11:10 -080019 this.$state.go('xos.dashboard');
Matteo Scandolof6acdbe2016-12-13 10:29:37 -080020 })
21 .catch(e => console.error);
22 }
23}
24
25export const xosLogin: angular.IComponentOptions = {
26 template: require('./login.html'),
27 controllerAs: 'vm',
28 controller: LoginCtrl
29};