When a user tries to login on the CLI without logging out from the previous
session, a text should be displayed with the client_id from the active
session. For some reason, the output displays an undefined string as part of
the client_id.
Code changes
There is a method called exitIfAuthed() that handles this behavior:
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 + "."),
true,
);
}
}
stateService.getEntityType() is returning undefined because it is not set
anywhere. This call isn't necessary at all. All authentication in Directory
Connector is done with organization-based API keys. This means the entity
type is always "organization". The best solution here would be to remove the
unused StateService methods and use a static string instead of the broken
type variable.
Screenshots
The changes in this PR result in the following error message being displayed:
Fix warning when attempting a double login in the cli
Type of change
Objective
When a user tries to login on the CLI without logging out from the previous session, a text should be displayed with the client_id from the active session. For some reason, the output displays an undefined string as part of the client_id.
Code changes
There is a method called
exitIfAuthed()
that handles this behavior:stateService.getEntityType()
is returning undefined because it is not set anywhere. This call isn't necessary at all. All authentication in Directory Connector is done with organization-based API keys. This means the entity type is always "organization". The best solution here would be to remove the unusedStateService
methods and use a static string instead of the brokentype
variable.Screenshots
The changes in this PR result in the following error message being displayed:
References