25 lines
711 B
TypeScript
25 lines
711 B
TypeScript
import { Component, computed, inject } from '@angular/core';
|
|
import { AuthService } from '../service/auth.service';
|
|
import { RouterLink } from '@angular/router';
|
|
|
|
@Component({
|
|
selector: 'app-header',
|
|
imports: [RouterLink],
|
|
templateUrl: './header.html',
|
|
styleUrl: './header.css',
|
|
})
|
|
export class Header {
|
|
private readonly authService = inject(AuthService);
|
|
|
|
protected readonly username = this.authService.username;
|
|
protected readonly isLoggedIn = computed(() => !!this.authService.accessToken());
|
|
|
|
protected async loginClick() {
|
|
await this.authService.login('test-user', 'test');
|
|
}
|
|
|
|
protected async logoutClick() {
|
|
await this.authService.logout();
|
|
}
|
|
}
|