39 lines
950 B
TypeScript
39 lines
950 B
TypeScript
import { AuthenticationState } from './AuthenticationState';
|
|
|
|
export class BrowserAuthenticationState {
|
|
private readonly cookiesValid: boolean;
|
|
private readonly pageAuthenticated: boolean;
|
|
|
|
constructor(cookiesValid: boolean, pageAuthenticated: boolean) {
|
|
this.cookiesValid = cookiesValid;
|
|
this.pageAuthenticated = pageAuthenticated;
|
|
}
|
|
|
|
isFullyAuthenticated(): boolean {
|
|
return this.cookiesValid && this.pageAuthenticated;
|
|
}
|
|
|
|
getAuthenticationState(): AuthenticationState {
|
|
if (!this.cookiesValid) {
|
|
return AuthenticationState.UNKNOWN;
|
|
}
|
|
|
|
if (!this.pageAuthenticated) {
|
|
return AuthenticationState.EXPIRED;
|
|
}
|
|
|
|
return AuthenticationState.AUTHENTICATED;
|
|
}
|
|
|
|
requiresReauthentication(): boolean {
|
|
return !this.isFullyAuthenticated();
|
|
}
|
|
|
|
getCookieValidity(): boolean {
|
|
return this.cookiesValid;
|
|
}
|
|
|
|
getPageAuthenticationStatus(): boolean {
|
|
return this.pageAuthenticated;
|
|
}
|
|
} |