From 3a2b92b3ffc7dabeb57b27a06d9f642e2340c5c0 Mon Sep 17 00:00:00 2001
From: Phan Huy Tran
Date: Wed, 12 Feb 2025 12:19:31 +0100
Subject: [PATCH] feat: Convert login button to hompage button when user is
authenticated
---
.../src/app/landing-page/landing-page.component.html | 6 +++++-
.../src/app/landing-page/landing-page.component.ts | 12 ++++++++++--
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/frontend/src/app/landing-page/landing-page.component.html b/frontend/src/app/landing-page/landing-page.component.html
index aa8bbd8..944881c 100644
--- a/frontend/src/app/landing-page/landing-page.component.html
+++ b/frontend/src/app/landing-page/landing-page.component.html
@@ -1 +1,5 @@
-
+@if (isLoggedIn) {
+
+} @else {
+
+}
diff --git a/frontend/src/app/landing-page/landing-page.component.ts b/frontend/src/app/landing-page/landing-page.component.ts
index f7509cf..f5fee0c 100644
--- a/frontend/src/app/landing-page/landing-page.component.ts
+++ b/frontend/src/app/landing-page/landing-page.component.ts
@@ -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` });