move isLoggedIn logic to auth context

This commit is contained in:
Mads Rasmussen
2023-11-10 12:42:25 +01:00
parent 58f4cf6be6
commit 1f17739f59
2 changed files with 8 additions and 7 deletions

View File

@@ -162,12 +162,6 @@ export class UmbAppElement extends UmbLitElement {
OpenAPI.TOKEN = () => this.#authContext!.getLatestToken();
OpenAPI.WITH_CREDENTIALS = true;
}
if (this.#authContext?.isAuthorized()) {
this.#authContext?.setLoggedIn(true);
} else {
this.#authContext?.setLoggedIn(false);
}
}
#redirect() {

View File

@@ -32,7 +32,14 @@ export class UmbAuthContext extends UmbBaseController implements IUmbAuth {
}
isAuthorized() {
return this.isBypassed ? true : this.#authFlow.isAuthorized();
if (this.isBypassed) {
this.#isLoggedIn.next(true);
return true;
} else {
const isAuthorized = this.#authFlow.isAuthorized();
this.#isLoggedIn.next(isAuthorized);
return isAuthorized;
}
}
setInitialState(): Promise<void> {