26 lines
958 B
TypeScript
26 lines
958 B
TypeScript
import { ChangeDetectionStrategy, Component, inject, OnInit } from '@angular/core';
|
|
import { KeycloakService } from 'keycloak-angular';
|
|
import { Router } from '@angular/router';
|
|
import { UserService } from '@service/user.service';
|
|
|
|
@Component({
|
|
selector: 'app-login-success',
|
|
standalone: true,
|
|
imports: [],
|
|
templateUrl: './login-success.component.html',
|
|
styleUrl: './login-success.component.css',
|
|
changeDetection: ChangeDetectionStrategy.OnPush,
|
|
})
|
|
export default class LoginSuccessComponent implements OnInit {
|
|
private userService: UserService = inject(UserService);
|
|
private keycloakService: KeycloakService = inject(KeycloakService);
|
|
private router: Router = inject(Router);
|
|
|
|
async ngOnInit() {
|
|
const userProfile = await this.keycloakService.loadUserProfile();
|
|
const user = await this.userService.getOrCreateUser(userProfile);
|
|
sessionStorage.setItem('user', JSON.stringify(user));
|
|
|
|
this.router.navigate(['home']);
|
|
}
|
|
}
|