Explorar el Código

Forces a logout if no valid auth is found

main
Eric Amodio hace 2 años
padre
commit
50b1b3d478
Se han modificado 1 ficheros con 13 adiciones y 2 borrados
  1. +13
    -2
      src/premium/subscription/subscriptionService.ts

+ 13
- 2
src/premium/subscription/subscriptionService.ts Ver fichero

@ -1,6 +1,7 @@
import {
authentication,
AuthenticationSession,
AuthenticationSessionsChangeEvent,
version as codeVersion,
commands,
Disposable,
@ -40,6 +41,7 @@ import { createFromDateDelta } from '../../system/date';
import { gate } from '../../system/decorators/gate';
import { debug, log } from '../../system/decorators/log';
import { memoize } from '../../system/decorators/memoize';
import { once } from '../../system/function';
import { pluralize } from '../../system/string';
// TODO: What user-agent should we use?
@ -64,7 +66,10 @@ export class SubscriptionService implements Disposable {
private _statusBarSubscription: StatusBarItem | undefined;
constructor(private readonly container: Container) {
this._disposable = this.container.onReady(this.onReady, this);
this._disposable = Disposable.from(
once(container.onReady)(this.onReady, this),
authentication.onDidChangeSessions(this.onAuthenticationChanged, this),
);
this.changeSubscription(this.getStoredSubscription(), true);
setTimeout(() => void this.ensureSession(false), 10000);
@ -76,6 +81,12 @@ export class SubscriptionService implements Disposable {
this._disposable.dispose();
}
private onAuthenticationChanged(e: AuthenticationSessionsChangeEvent): void {
if (e.provider.id !== SubscriptionService.authenticationProviderId) return;
void this.ensureSession(false);
}
@memoize()
private get baseApiUri(): Uri {
const { env } = this.container;
@ -515,7 +526,7 @@ export class SubscriptionService implements Disposable {
}
if (session == null) {
this.updateContext();
this.logout();
return session ?? null;
}

Cargando…
Cancelar
Guardar