blob: 413290c18104002abe8a30a6a4c3dae1b68998ee [file] [log] [blame]
Matteo Scandolo43ffb672016-12-02 14:49:58 -08001/// <reference path="../../../../typings/index.d.ts"/>
2import {Component} from '@angular/core';
3import {Router} from '@angular/router';
4import {IAuthRequest, IAuthResponse} from '../../interfaces/auth.interface';
5import {StyleConfig} from '../../config/style.config';
6import {AuthService} from '../../services/rest/auth.service';
7
8export class Auth {
9 constructor(
10 public username,
11 public password
12 ){
13 }
14}
15
16@Component({
17 selector: 'xos-login',
18 template: require('./login.html'),
19 providers: [AuthService],
20})
21export class LoginComponent {
22 public auth:IAuthRequest;
23 public brandName;
24 constructor(private AuthService: AuthService, private router:Router) {
25 this.auth = new Auth('', '');
26 this.brandName = StyleConfig.projectName;
27 }
28
29 onSubmit(auth:IAuthRequest){
30 this.AuthService.login(auth)
31 .subscribe(
32 (user:IAuthResponse) => {
33 this.router.navigate(['/']);
34 }
35 )
36 }
37}
38