Skip to content

Follow up 944: authentication sessions are not persistent #1003

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
#944: Fixed auth. sessions not persistent
  • Loading branch information
davegarthsimpson committed May 18, 2022
commit ff13922e78f344aeaece9263e63d01ae10f11ef2
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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