25 lines
485 B
TypeScript
25 lines
485 B
TypeScript
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);
|
|
}
|
|
}
|