20230731-angular-Erwieterung-authantificationAnd

This commit is contained in:
2023-07-31 12:36:17 +02:00
parent c7ba87409a
commit 6ae0d27dd4
24 changed files with 348 additions and 26 deletions

View File

@@ -0,0 +1,24 @@
import { Injectable } from '@angular/core';
import { BehaviorSubject } from 'rxjs';
@Injectable({
providedIn: 'root',
})
export class AuthService {
private _isAuthenticated$ = new BehaviorSubject(true);
readonly isAuthenticated$ = this._isAuthenticated$.asObservable();
constructor() {}
get isAuthenticated() {
return this._isAuthenticated$.value;
}
login() {
this._isAuthenticated$.next(true);
}
logout() {
this._isAuthenticated$.next(false);
}
}