From e8d2f53a934777f57eab7ba9f5e206c80a3722fb Mon Sep 17 00:00:00 2001 From: Phan Huy Tran Date: Wed, 12 Feb 2025 09:27:41 +0100 Subject: [PATCH] Add logout and login functionality --- frontend/src/app/homepage/homepage/homepage.component.ts | 6 ++++-- frontend/src/app/landing-page/landing-page.component.html | 1 + frontend/src/app/landing-page/landing-page.component.ts | 7 ++++++- 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/frontend/src/app/homepage/homepage/homepage.component.ts b/frontend/src/app/homepage/homepage/homepage.component.ts index 0b720e5..a4637e0 100644 --- a/frontend/src/app/homepage/homepage/homepage.component.ts +++ b/frontend/src/app/homepage/homepage/homepage.component.ts @@ -1,4 +1,5 @@ -import {ChangeDetectionStrategy, Component} from '@angular/core'; +import {ChangeDetectionStrategy, Component, inject} from '@angular/core'; +import {KeycloakService} from "keycloak-angular"; @Component({ selector: 'app-homepage', @@ -9,9 +10,10 @@ import {ChangeDetectionStrategy, Component} from '@angular/core'; changeDetection: ChangeDetectionStrategy.OnPush }) export class HomepageComponent { + private KeycloakService: KeycloakService = inject(KeycloakService); onLogout() { - //TODO implement + this.KeycloakService.logout(); } openUserInfo() { diff --git a/frontend/src/app/landing-page/landing-page.component.html b/frontend/src/app/landing-page/landing-page.component.html index e69de29..06f5418 100644 --- a/frontend/src/app/landing-page/landing-page.component.html +++ b/frontend/src/app/landing-page/landing-page.component.html @@ -0,0 +1 @@ + diff --git a/frontend/src/app/landing-page/landing-page.component.ts b/frontend/src/app/landing-page/landing-page.component.ts index ed8aba1..7ea8521 100644 --- a/frontend/src/app/landing-page/landing-page.component.ts +++ b/frontend/src/app/landing-page/landing-page.component.ts @@ -1,4 +1,5 @@ -import { Component } from '@angular/core'; +import {Component, inject} from '@angular/core'; +import {KeycloakService} from "keycloak-angular"; @Component({ selector: 'app-landing-page', @@ -7,5 +8,9 @@ import { Component } from '@angular/core'; templateUrl: './landing-page.component.html', }) export class LandingPageComponent { + private keycloakService: KeycloakService = inject(KeycloakService); + login() { + this.keycloakService.login(); + } }