Matteo Scandolo | 035c593 | 2016-12-14 09:55:15 -0800 | [diff] [blame^] | 1 | import {AuthService} from '../../datasources/rest/auth.rest'; |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 2 | |
| 3 | class 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 Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 19 | this.$state.go('xos.dashboard'); |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 20 | }) |
| 21 | .catch(e => console.error); |
| 22 | } |
| 23 | } |
| 24 | |
| 25 | export const xosLogin: angular.IComponentOptions = { |
| 26 | template: require('./login.html'), |
| 27 | controllerAs: 'vm', |
| 28 | controller: LoginCtrl |
| 29 | }; |