feat(auth): add login and registration modal functionality
This commit is contained in:
parent
5bbfa5994e
commit
0079ee7bf2
11 changed files with 212 additions and 55 deletions
|
@ -12,12 +12,13 @@
|
|||
|
||||
<div class="hidden md:flex items-center space-x-4">
|
||||
@if (!isLoggedIn()) {
|
||||
<a routerLink="/login" class="button-primary px-4 py-1.5">Anmelden</a>
|
||||
<a
|
||||
routerLink="/register"
|
||||
<button (click)="showLogin.emit()" class="button-primary px-4 py-1.5">Anmelden</button>
|
||||
<button
|
||||
(click)="showRegister.emit()"
|
||||
class="bg-emerald-700 text-white hover:bg-emerald-600 px-4 py-1.5 rounded"
|
||||
>Registrieren</a
|
||||
>
|
||||
Registrieren
|
||||
</button>
|
||||
}
|
||||
@if (isLoggedIn()) {
|
||||
<div
|
||||
|
@ -71,14 +72,15 @@
|
|||
<a routerLink="/games" class="nav-mobile-link">Spiele</a>
|
||||
<div class="pt-2 space-y-2">
|
||||
@if (!isLoggedIn()) {
|
||||
<a routerLink="/login" class="button-primary w-full py-1.5 block text-center"
|
||||
>Anmelden</a
|
||||
>
|
||||
<a
|
||||
routerLink="/register"
|
||||
<button (click)="showLogin.emit()" class="button-primary w-full py-1.5 block text-center">
|
||||
Anmelden
|
||||
</button>
|
||||
<button
|
||||
(click)="showRegister.emit()"
|
||||
class="bg-emerald-700 text-white hover:bg-emerald-600 w-full py-1.5 rounded block text-center"
|
||||
>Registrieren</a
|
||||
>
|
||||
Registrieren
|
||||
</button>
|
||||
}
|
||||
@if (isLoggedIn()) {
|
||||
<button (click)="logout()" class="button-primary w-full py-1.5">Abmelden</button>
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import {
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
EventEmitter,
|
||||
inject,
|
||||
OnDestroy,
|
||||
OnInit,
|
||||
Output,
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { RouterModule } from '@angular/router';
|
||||
|
@ -26,6 +28,9 @@ export class NavbarComponent implements OnInit, OnDestroy {
|
|||
private authSubscription!: Subscription;
|
||||
public balance = signal(0);
|
||||
|
||||
@Output() showLogin = new EventEmitter<void>();
|
||||
@Output() showRegister = new EventEmitter<void>();
|
||||
|
||||
ngOnInit() {
|
||||
this.authSubscription = this.authService.userSubject.subscribe({
|
||||
next: (user) => {
|
||||
|
|
Reference in a new issue