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) { |
Matteo Scandolo | 266907e | 2016-12-20 13:41:42 -0800 | [diff] [blame^] | 14 | console.log(username, password); |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 15 | this.authService.login({ |
| 16 | username: username, |
| 17 | password: password |
| 18 | }) |
| 19 | .then(res => { |
Matteo Scandolo | 9f87f30 | 2016-12-13 18:11:10 -0800 | [diff] [blame] | 20 | this.$state.go('xos.dashboard'); |
Matteo Scandolo | f6acdbe | 2016-12-13 10:29:37 -0800 | [diff] [blame] | 21 | }) |
| 22 | .catch(e => console.error); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | export const xosLogin: angular.IComponentOptions = { |
| 27 | template: require('./login.html'), |
| 28 | controllerAs: 'vm', |
| 29 | controller: LoginCtrl |
| 30 | }; |