37 lines
996 B
TypeScript
37 lines
996 B
TypeScript
import { Component, OnInit } from '@angular/core';
|
|
import { CommonModule } from '@angular/common';
|
|
import { ActivatedRoute, Params, Router } from '@angular/router';
|
|
import { UserService } from '../services/user.service';
|
|
|
|
@Component({
|
|
selector: 'app-callback',
|
|
standalone: true,
|
|
templateUrl: './callback.component.html',
|
|
})
|
|
export class CallbackComponent implements OnInit {
|
|
constructor(
|
|
private route: ActivatedRoute,
|
|
private router: Router,
|
|
private userService: UserService
|
|
) {}
|
|
|
|
ngOnInit(): void {
|
|
this.route.queryParams.subscribe((params) => {
|
|
console.log(params);
|
|
|
|
if (params['email'] && params['name'] && params['picture']) {
|
|
this.userService.setAuth({
|
|
email: params['email'],
|
|
name: params['name'],
|
|
picture: params['picture'],
|
|
});
|
|
}
|
|
|
|
if (params['redirect_to']) {
|
|
this.router.navigate([params['redirect_to']]);
|
|
} else {
|
|
this.router.navigate(['/']);
|
|
}
|
|
});
|
|
}
|
|
}
|