Skip to content
This repository has been archived by the owner on May 31, 2024. It is now read-only.

Commit

Permalink
fix: fix azure login
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenplc committed Jan 3, 2024
1 parent 8b202ba commit b69aaa4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@lemoncloud/lemon-front-lib",
"version": "1.4.0",
"version": "1.4.1",
"description": "Web Core Library for Lemoncloud",
"exports": "./dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
30 changes: 22 additions & 8 deletions src/core/identity.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ export class IdentityService {
const isAWS = this.options.cloud === 'aws';
const isAzure = this.options.cloud === 'azure';
if (isAWS) {
this.logger.log('Using AWS platform');
return this.buildAWSCredentialsByToken(token);
}
if (isAzure) {
this.logger.log('Using AWS platform');
this.logger.log('Using Azure platform');
return await this.lemonStorage.saveLemonOAuthToken(token);
}
}
Expand Down Expand Up @@ -170,6 +171,8 @@ export class IdentityService {
}

async isAuthenticated(): Promise<boolean> {
const isAWS = await this.lemonStorage.getItem(`accessKeyId`);

const hasCachedToken = await this.lemonStorage.hasCachedToken();
if (!hasCachedToken) {
return false;
Expand All @@ -189,15 +192,26 @@ export class IdentityService {
return false;
}

return new Promise(resolve => {
(<AWS.Credentials>AWS.config.credentials).get(error => {
if (error) {
this.logger.error('get AWSConfig.credentials error: ', error);
}
const isAuthenticated = !error;
if (isAWS) {
return new Promise(resolve => {
(<AWS.Credentials>AWS.config.credentials).get(error => {
if (error) {
this.logger.error('get AWSConfig.credentials error: ', error);
}
const isAuthenticated = !error;
resolve(isAuthenticated);
});
});
}

// Note: Temporary solution that implies use of Azure platform since 'accessKeyId' property
// is AWS specific and library currently support AWS and Azure only.
if (!isAWS) {
return new Promise(resolve => {
const isAuthenticated = true;
resolve(isAuthenticated);
});
});
}
}

logout(): Promise<boolean> {
Expand Down

0 comments on commit b69aaa4

Please sign in to comment.