20230731-angular-Erwieterung-authantificationAnd
This commit is contained in:
24
src/app/shared/auth.service.ts
Normal file
24
src/app/shared/auth.service.ts
Normal 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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user