blob: 05cc11da1292c296191e165b80b5222f5f9cfe08 [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
Matteo Scandolo0f77c502016-12-06 16:46:00 -08008import {AppConfig} from '../../config/app.config';
9
Matteo Scandolo43ffb672016-12-02 14:49:58 -080010export class Auth {
11 constructor(
12 public username,
13 public password
14 ){
15 }
16}
17
18@Component({
19 selector: 'xos-login',
20 template: require('./login.html'),
21 providers: [AuthService],
22})
23export class LoginComponent {
24 public auth:IAuthRequest;
25 public brandName;
26 constructor(private AuthService: AuthService, private router:Router) {
27 this.auth = new Auth('', '');
28 this.brandName = StyleConfig.projectName;
29 }
30
31 onSubmit(auth:IAuthRequest){
32 this.AuthService.login(auth)
33 .subscribe(
34 (user:IAuthResponse) => {
35 this.router.navigate(['/']);
36 }
37 )
38 }
39}
40