From 4a6995be18b15de1834a39c8921a0e4109671bb6 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 3 Jun 2016 22:08:03 +0200 Subject: First draft to use webpack instead of systemjs --- client/src/app/login/index.ts | 1 + client/src/app/login/login.component.html | 14 ++++++++++++ client/src/app/login/login.component.ts | 36 +++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 client/src/app/login/index.ts create mode 100644 client/src/app/login/login.component.html create mode 100644 client/src/app/login/login.component.ts (limited to 'client/src/app/login') diff --git a/client/src/app/login/index.ts b/client/src/app/login/index.ts new file mode 100644 index 000000000..69c16441f --- /dev/null +++ b/client/src/app/login/index.ts @@ -0,0 +1 @@ +export * from './login.component'; diff --git a/client/src/app/login/login.component.html b/client/src/app/login/login.component.html new file mode 100644 index 000000000..940694515 --- /dev/null +++ b/client/src/app/login/login.component.html @@ -0,0 +1,14 @@ +

Login

+
+
+ + +
+ +
+ + +
+ + +
diff --git a/client/src/app/login/login.component.ts b/client/src/app/login/login.component.ts new file mode 100644 index 000000000..9d88536ca --- /dev/null +++ b/client/src/app/login/login.component.ts @@ -0,0 +1,36 @@ +import { Component } from '@angular/core'; +import { Router } from '@angular/router-deprecated'; + +import { AuthService, AuthStatus, User } from '../shared'; + +@Component({ + selector: 'my-login', + template: require('./login.component.html') +}) + +export class LoginComponent { + constructor( + private authService: AuthService, + private router: Router + ) {} + + login(username: string, password: string) { + this.authService.login(username, password).subscribe( + result => { + const user = new User(username, result); + user.save(); + + this.authService.setStatus(AuthStatus.LoggedIn); + + this.router.navigate(['VideosList']); + }, + error => { + if (error.error === 'invalid_grant') { + alert('Credentials are invalid.'); + } else { + alert(`${error.error}: ${error.error_description}`); + } + } + ); + } +} -- cgit v1.2.3