feat: Convert login button to hompage button when user is authenticated (CAS-33) #22

Merged
ptran merged 3 commits from feat/login-to-homepage-button into main 2025-02-12 11:35:01 +00:00
2 changed files with 15 additions and 3 deletions
Showing only changes of commit 3a2b92b3ff - Show all commits

View File

@ -1 +1,5 @@
<button (click)="login()">Einloggen</button>
@if (isLoggedIn) {
<button routerLink="/home">Zur Homepage</button>
} @else {
<button (click)="login()">Einloggen</button>
}

View File

@ -1,16 +1,24 @@
import { Component, inject } from '@angular/core';
import { KeycloakService } from 'keycloak-angular';
import {RouterLink} from "@angular/router";
@Component({
selector: 'app-landing-page',
standalone: true,
imports: [],
imports: [
RouterLink
],
templateUrl: './landing-page.component.html',
})
export class LandingPageComponent {
public isLoggedIn = false;
private keycloakService: KeycloakService = inject(KeycloakService);
login() {
private ngOnInit() {
this.isLoggedIn = this.keycloakService.isLoggedIn();
}
public login() {
const baseUrl = window.location.origin;
this.keycloakService.login({ redirectUri: `${baseUrl}/home` });