Skip to content

Commit

Permalink
#944: Fixed auth. sessions not persistent (#992)
Browse files Browse the repository at this point in the history
  • Loading branch information
davegarthsimpson committed May 23, 2022
1 parent b407d0a commit b8c718c
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
Expand Up @@ -49,7 +49,10 @@ export class AuthenticationClientService
this.service
.session()
.then((session) => this.notifySessionDidChange(session));

this.setOptions();
this.service.initAuthSession()

this.arduinoPreferences.onPreferenceChanged((event) => {
if (event.preferenceName.startsWith('arduino.auth.')) {
this.setOptions();
Expand Down
Expand Up @@ -23,6 +23,7 @@ export interface AuthenticationService
session(): Promise<AuthenticationSession | undefined>;
disposeClient(client: AuthenticationServiceClient): void;
setOptions(authOptions: AuthOptions): void;
initAuthSession(): Promise<void>;
}

export interface AuthenticationServiceClient {
Expand Down
Expand Up @@ -19,6 +19,8 @@ export class AuthenticationServiceImpl
protected readonly delegate = new ArduinoAuthenticationProvider();
protected readonly clients: AuthenticationServiceClient[] = [];
protected readonly toDispose = new DisposableCollection();

private initialized = false;

async onStart(): Promise<void> {
this.toDispose.pushAll([
Expand All @@ -42,7 +44,13 @@ export class AuthenticationServiceImpl
this.clients.forEach((client) => this.disposeClient(client))
),
]);
await this.delegate.init();
}

async initAuthSession(): Promise<void> {
if (!this.initialized) {
await this.delegate.init();
this.initialized = true
}
}

setOptions(authOptions: AuthOptions) {
Expand Down

0 comments on commit b8c718c

Please sign in to comment.