refactor: Redirect to orginal route after login, restructure project files
This commit is contained in:
parent
29d3c53b19
commit
704cc22858
6 changed files with 20 additions and 12 deletions
29
frontend/src/app/feature/home/home.component.html
Normal file
29
frontend/src/app/feature/home/home.component.html
Normal file
|
@ -0,0 +1,29 @@
|
|||
<nav class="bg-black border-b border-amber-600/30 sticky top-0 z-50">
|
||||
<div class="container mx-auto px-4 py-3 flex justify-between items-center">
|
||||
<!-- logo goes here -->
|
||||
<div class="flex gap-4">
|
||||
<button class="btn-primary" (click)="logout()">Ausloggen</button>
|
||||
</div>
|
||||
<div>
|
||||
<button class="btn-primary">Benutzer</button>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="grid grid-cols-3">
|
||||
<div class="w-1/3 h-1/4">
|
||||
<p>Spiel Vorschau</p>
|
||||
<p>Spiel Name</p>
|
||||
<button type="button" class="btn-primary">Jetzt spielen</button>
|
||||
</div>
|
||||
<div class="w-1/3 h-1/4">
|
||||
<p>Spiel Vorschau</p>
|
||||
<p>Spiel Name</p>
|
||||
<button type="button" class="btn-primary">Jetzt spielen</button>
|
||||
</div>
|
||||
<div class="w-1/3 h-1/4">
|
||||
<p>Spiel Vorschau</p>
|
||||
<p>Spiel Name</p>
|
||||
<button type="button" class="btn-primary">Jetzt spielen</button>
|
||||
</div>
|
||||
</div>
|
19
frontend/src/app/feature/home/home.component.ts
Normal file
19
frontend/src/app/feature/home/home.component.ts
Normal file
|
@ -0,0 +1,19 @@
|
|||
import { ChangeDetectionStrategy, Component, inject } from '@angular/core';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
|
||||
@Component({
|
||||
selector: 'app-homepage',
|
||||
standalone: true,
|
||||
imports: [],
|
||||
templateUrl: './home.component.html',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class HomeComponent {
|
||||
private keycloakService: KeycloakService = inject(KeycloakService);
|
||||
|
||||
logout() {
|
||||
const baseUrl = window.location.origin;
|
||||
|
||||
this.keycloakService.logout(`${baseUrl}/`);
|
||||
}
|
||||
}
|
5
frontend/src/app/feature/landing/landing.component.html
Normal file
5
frontend/src/app/feature/landing/landing.component.html
Normal file
|
@ -0,0 +1,5 @@
|
|||
@if (isLoggedIn) {
|
||||
<button routerLink="/home">Zur Homepage</button>
|
||||
} @else {
|
||||
<button (click)="login()">Einloggen</button>
|
||||
}
|
21
frontend/src/app/feature/landing/landing.component.ts
Normal file
21
frontend/src/app/feature/landing/landing.component.ts
Normal file
|
@ -0,0 +1,21 @@
|
|||
import { Component, inject } from '@angular/core';
|
||||
import { KeycloakService } from 'keycloak-angular';
|
||||
import { RouterLink } from '@angular/router';
|
||||
|
||||
@Component({
|
||||
selector: 'app-landing',
|
||||
standalone: true,
|
||||
imports: [RouterLink],
|
||||
templateUrl: './landing.component.html',
|
||||
})
|
||||
export class LandingComponent {
|
||||
private keycloakService: KeycloakService = inject(KeycloakService);
|
||||
|
||||
public isLoggedIn = this.keycloakService.isLoggedIn();
|
||||
|
||||
public login() {
|
||||
const baseUrl = window.location.origin;
|
||||
|
||||
this.keycloakService.login({ redirectUri: `${baseUrl}/home` });
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue