Files
pas/Web/src/app/pages/authentication/callback/callback.component.ts

32 lines
1.1 KiB
TypeScript
Executable File

import { Component } from '@angular/core';
import { Router, RouterModule } from '@angular/router';
import { CoreService } from '../../../services/core.service';
import { MaterialModule } from '../../../material.module';
import { AuthenticationService } from '../../../services/authentication.service';
import { NgScrollbarModule } from "ngx-scrollbar";
@Component({
selector: 'app-callback',
imports: [RouterModule, MaterialModule, NgScrollbarModule],
templateUrl: './callback.component.html',
})
export class CallbackComponent {
options: any;
profile: any;
constructor(private settings: CoreService, private as: AuthenticationService, private router: Router) {
this.options = this.settings.getOptions();
// Handle the OAuth2 callback and load user profile
this.as
.handleCallback()
.then(_ => {
console.log('Login successful');
this.profile = this.as.profile;
this.router.navigate(['/dashboard']);
}).catch(err => {
console.error('Error handling callback', err);
});
}
}