in vscode/qodana/src/core/auth/index.ts [83:108]
static async create(context: vscode.ExtensionContext): Promise<Auth> {
let instance = new Auth(context);
let savedServer = context.globalState.get(SERVER) as string;
let authState = await Auth.getAuthState(context);
let newState: AuthState_;
if (authState instanceof Unauthorized) {
newState = new NotAuthorizedImpl(context, instance.stateEmitter);
} else {
let environment = new CloudEnvironment(savedServer);
let state = authState as InternalAuthorized;
let auth: AuthorizationResponseData = {
access: state.token, expires_at: state.expires, refresh: state.refreshToken
};
let id = context.globalState.get(USER_ID) as string;
let fullName = context.globalState.get(USER_FULL_NAME) as string;
let userName = context.globalState.get(USER_NAME) as string;
let userInfo = {
id: id,
fullName: fullName,
username: userName,
};
newState = await AuthorizedImpl.create(context, instance.stateEmitter, environment, auth, userInfo);
}
instance.stateEmitter.fire(newState);
return instance;
}