You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
843 B

// src/app/google-callback/google-callback.component.ts
import { Component, OnInit } from '@angular/core';
import { AuthService } from '../auth.service';
import { Router, ActivatedRoute } from '@angular/router';
@Component({
selector: 'app-google-callback',
template: '<p>Loading...</p>',
styles: []
})
export class GoogleCallbackComponent implements OnInit {
constructor(
private authService: AuthService,
private router: Router,
private route: ActivatedRoute
) {}
ngOnInit(): void {
this.route.queryParams.subscribe(params => {
console.log("callback-hit");
const token = params['token'];
if (token) {
localStorage.setItem('token', token);
this.router.navigate(['/']);
} else {
this.router.navigate(['/login']);
}
});
}
}