401 unauthorized requests now redirect users to the login page

This commit is contained in:
Isaac Abadi
2020-12-19 13:03:49 -05:00
parent e75b56ad3f
commit 7e06d30205
3 changed files with 39 additions and 3 deletions

View File

@@ -27,7 +27,7 @@ export class LoginComponent implements OnInit {
constructor(private postsService: PostsService, private snackBar: MatSnackBar, private router: Router) { }
ngOnInit(): void {
if (this.postsService.isLoggedIn) {
if (this.postsService.isLoggedIn && localStorage.getItem('jwt_token') !== 'null') {
this.router.navigate(['/home']);
}
this.postsService.service_initialized.subscribe(init => {