Skip to content

Commit

Permalink
Fix warning when attempting a double login in the cli (#468)
Browse files Browse the repository at this point in the history
* Replace call to `getEntityType` with a static string

* Delete several unused `StateService` methods
  • Loading branch information
addisonbeck committed Mar 19, 2024
1 parent 5ce3b01 commit cc05bcb
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 33 deletions.
3 changes: 0 additions & 3 deletions jslib/common/src/abstractions/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,6 @@ export abstract class StateService<T extends Account = Account> {
getEncryptedSends: (options?: StorageOptions) => Promise<{ [id: string]: SendData }>;
setEncryptedSends: (value: { [id: string]: SendData }, options?: StorageOptions) => Promise<void>;
getEntityId: (options?: StorageOptions) => Promise<string>;
setEntityId: (value: string, options?: StorageOptions) => Promise<void>;
getEntityType: (options?: StorageOptions) => Promise<any>;
setEntityType: (value: string, options?: StorageOptions) => Promise<void>;
getEnvironmentUrls: (options?: StorageOptions) => Promise<EnvironmentUrls>;
setEnvironmentUrls: (value: EnvironmentUrls, options?: StorageOptions) => Promise<void>;
getEquivalentDomains: (options?: StorageOptions) => Promise<any>;
Expand Down
28 changes: 0 additions & 28 deletions jslib/common/src/services/state.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1355,34 +1355,6 @@ export class StateService<
)?.profile?.entityId;
}

async setEntityId(value: string, options?: StorageOptions): Promise<void> {
const account = await this.getAccount(
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()),
);
account.profile.entityId = value;
await this.saveAccount(
account,
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()),
);
}

async getEntityType(options?: StorageOptions): Promise<any> {
return (
await this.getAccount(this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()))
)?.profile?.entityType;
}

async setEntityType(value: string, options?: StorageOptions): Promise<void> {
const account = await this.getAccount(
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()),
);
account.profile.entityType = value;
await this.saveAccount(
account,
this.reconcileOptions(options, await this.defaultOnDiskLocalOptions()),
);
}

async getEnvironmentUrls(options?: StorageOptions): Promise<EnvironmentUrls> {
if (this.state.activeUserId == null) {
return await this.getGlobalEnvironmentUrls(options);
Expand Down
3 changes: 1 addition & 2 deletions src/program.ts
Original file line number Diff line number Diff line change
Expand Up @@ -301,10 +301,9 @@ export class Program extends BaseProgram {
async exitIfAuthed() {
const authed = await this.stateService.getIsAuthenticated();
if (authed) {
const type = await this.stateService.getEntityType();
const id = await this.stateService.getEntityId();
this.processResponse(
Response.error("You are already logged in as " + type + "." + id + "."),
Response.error("You are already logged in as organization." + id + "."),
true,
);
}
Expand Down

0 comments on commit cc05bcb

Please sign in to comment.