Files
Book-Monkey/src/app/shared/auth.service.ts

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);
}
}