Skip to content

Instantly share code, notes, and snippets.

@4skinSkywalker
Last active March 28, 2019 15:28
Show Gist options
  • Select an option

  • Save 4skinSkywalker/8d5e24002845fbc5fa3ad271d1070310 to your computer and use it in GitHub Desktop.

Select an option

Save 4skinSkywalker/8d5e24002845fbc5fa3ad271d1070310 to your computer and use it in GitHub Desktop.
import { Component, OnInit } from '@angular/core';
import { AuthService } from '../services/auth.service';
import { Router } from '@angular/router'
import { UnauthError } from '../common/unauth-error'
import { AppError } from '../common/app-error'
@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: AppError) => { // look here
if (error instanceof UnauthError) {
return this.isInvalid = true
}
}
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment