Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 1x 3x 3x 3x 3x 3x 3x | import {
ChangeDetectionStrategy,
Component,
inject,
signal,
} from '@angular/core';
import type { WritableSignal } from '@angular/core';
import { Auth, signOut } from '@angular/fire/auth';
import { Router, RouterLink } from '@angular/router';
import { SpinnerComponent } from '~/app/shared/spinner/spinner.component';
/**
* Form to logout current user's session with Firebase Authentication.
*/
@Component({
selector: 'app-logout',
imports: [ RouterLink, SpinnerComponent ],
templateUrl: './logout.component.html',
changeDetection: ChangeDetectionStrategy.OnPush,
})
export class LogoutComponent {
/** During logout block the entire window to prevent User interaction with the application. */
public readonly $blockWindow: WritableSignal<boolean> = signal<boolean>(false);
private readonly _auth: Auth = inject(Auth);
private readonly _router: Router = inject(Router);
/**
* Show blocking spinner, logout the current user, navigates back to the default route.
*/
public async logout(): Promise<void> {
this.$blockWindow.set(true);
await signOut(this._auth);
await this._router.navigateByUrl('/'); // Navigate to root to allow Guards to handle final redirecting.
}
}
|