Last active
March 28, 2019 15:14
-
-
Save 4skinSkywalker/302f29e39bed2ac2c47539dc015f0a3d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Component, OnInit } from '@angular/core' | |
| import { AuthService } from '../services/auth.service' | |
| import { Router } from '@angular/router' | |
| @Component({ | |
| selector: 'app-login', | |
| templateUrl: './login.component.html', | |
| styleUrls: ['./login.component.css'] | |
| }) | |
| export class LoginComponent implements OnInit { | |
| isInvalid: boolean = false | |
| constructor( | |
| private authService: AuthService, | |
| private router: Router) { } | |
| ngOnInit() { | |
| } | |
| submit(f) { | |
| const credentials = f.value | |
| this.authService.login(credentials) | |
| .subscribe(result => { | |
| this.router.navigate(['']) | |
| }, | |
| error => { | |
| if (error === 'Unauthorized.') { | |
| this.isInvalid = true | |
| } | |
| }) | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment