#944: Fixed auth. sessions not persistent (#992)

This commit is contained in:
David Simpson 2022-05-23 09:52:44 +02:00 committed by GitHub
parent b407d0aee0
commit b8c718ce9e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 1 deletions

View File

@ -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();

View File

@ -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 {

View File

@ -20,6 +20,8 @@ export class AuthenticationServiceImpl
protected readonly clients: AuthenticationServiceClient[] = [];
protected readonly toDispose = new DisposableCollection();
private initialized = false;
async onStart(): Promise<void> {
this.toDispose.pushAll([
this.delegate,
@ -42,7 +44,13 @@ export class AuthenticationServiceImpl
this.clients.forEach((client) => this.disposeClient(client))
),
]);
}
async initAuthSession(): Promise<void> {
if (!this.initialized) {
await this.delegate.init();
this.initialized = true
}
}
setOptions(authOptions: AuthOptions) {