Skip to content

Commit ada37e1

Browse files
Login and logout are promises, should be awaited
1 parent 2150eec commit ada37e1

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

frontend/src/index.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ setupConsoleLogging();
3737
async function init() {
3838
console.info('Context:', IS_EMBEDDED ? 'iframe' : 'standalone');
3939

40-
const authenticated = await AuthService.init(getRealmParam() ?? 'master');
41-
if (!authenticated) {
42-
AuthService.login();
43-
}
40+
await AuthService.init(getRealmParam() ?? 'master');
41+
4442
// Setup OR icons
4543
setupORIcons();
4644

frontend/src/pages/app-layout.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ export class AppLayout extends LitElement {
3434
realm = '';
3535

3636
// Called before the initial Vaadin Router location is entered ('/'), only called once since its a parent route
37-
onBeforeEnter(location: RouterLocation) {
37+
async onBeforeEnter(location: RouterLocation) {
3838
if (!AuthService.authenticated) {
39-
AuthService.login();
39+
await AuthService.login();
4040
return;
4141
}
4242

frontend/src/services/auth-service.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,15 +95,15 @@ class AuthServiceClass {
9595
/**
9696
* Login to the Keycloak instance
9797
*/
98-
login() {
99-
this.keycloak?.login();
98+
async login() {
99+
await this.keycloak?.login();
100100
}
101101

102102
/**
103103
* Logout from the Keycloak instance
104104
*/
105-
logout() {
106-
this.keycloak?.logout();
105+
async logout() {
106+
await this.keycloak?.logout();
107107
this.stopUpdateTokenInterval();
108108
}
109109

0 commit comments

Comments
 (0)