]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/login/login.component.ts
Client: Add authHttp service that authentificates the http request and
[github/Chocobozzz/PeerTube.git] / client / src / app / login / login.component.ts
index 9d88536cabfb1f01152bb753450df155b7b8072a..ddd62462ebed68cbf100f00138c8f0d1e2cb6db1 100644 (file)
@@ -1,7 +1,7 @@
 import { Component } from '@angular/core';
-import { Router } from '@angular/router-deprecated';
+import { Router } from '@angular/router';
 
-import { AuthService, AuthStatus, User } from '../shared';
+import { AuthService } from '../shared';
 
 @Component({
   selector: 'my-login',
@@ -9,6 +9,8 @@ import { AuthService, AuthStatus, User } from '../shared';
 })
 
 export class LoginComponent {
+  error: string = null;
+
   constructor(
     private authService: AuthService,
     private router: Router
@@ -17,18 +19,17 @@ export class LoginComponent {
   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.error = null;
 
-        this.router.navigate(['VideosList']);
+        this.router.navigate(['/videos/list']);
       },
       error => {
+        console.error(error);
+
         if (error.error === 'invalid_grant') {
-          alert('Credentials are invalid.');
+          this.error = 'Credentials are invalid.';
         } else {
-          alert(`${error.error}: ${error.error_description}`);
+          this.error = `${error.error}: ${error.error_description}`;
         }
       }
     );