export the isAuthorized function

This commit is contained in:
Jacob Overgaard
2023-10-24 14:38:08 +02:00
parent 29328a332e
commit cea210a56c
3 changed files with 10 additions and 1 deletions

View File

@@ -219,7 +219,7 @@ export class UmbAuthFlow {
*
* @returns true if the user is logged in, false otherwise.
*/
loggedIn(): boolean {
isAuthorized(): boolean {
return !!this.#accessTokenResponse && this.#accessTokenResponse.isValid();
}

View File

@@ -34,6 +34,10 @@ export class UmbAuthContext implements IUmbAuth {
return this.#authFlow.makeAuthorizationRequest();
}
isAuthorized() {
return this.#authFlow.isAuthorized();
}
setInitialState(): Promise<void> {
return this.#authFlow.setInitialState();
}

View File

@@ -12,6 +12,11 @@ export interface IUmbAuth {
*/
setInitialState(): Promise<void>;
/**
* Checks if there is a token and it is still valid.
*/
isAuthorized(): boolean;
/**
* Gets the latest token from the Management API.
* If the token is expired, it will be refreshed.