Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/amplify-sdk/src/amplify-sdk.js
Original file line number Diff line number Diff line change
Expand Up @@ -469,7 +469,7 @@ export default class AmplifySDK {
});

try {
const url = createURL(`${this.platformUrl}/#/auth/org.select`, {
const url = createURL(`${this.platformUrl}/auth/org.select`, {
org_hint: org?.id,
redirect
});
Expand Down
24 changes: 22 additions & 2 deletions packages/amplify-sdk/src/authenticators/authenticator.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,8 +517,8 @@ export default class Authenticator {

let redirect = orgSelectedCallback.url;
// if we just authenticated using a IdP user (e.g. not 360)
if (account.auth.idp !== '360') {
redirect = createURL(`${this.platformUrl}/#/auth/org.select`, {
if (account.auth.idp !== '360' && await this.isAccountPartOfMultipleOrgs(account)) {
redirect = createURL(`${this.platformUrl}/auth/org.select`, {
redirect: orgSelectedCallback.url
});
}
Expand Down Expand Up @@ -579,6 +579,26 @@ export default class Authenticator {
return new Promise(resolve => setTimeout(resolve, 3000));
}

async isAccountPartOfMultipleOrgs(account) {
// Fetch auth session to determine if the account have multiple orgs
try {
const accessToken = account.auth.tokens.access_token;
log('Fetching auth session from platform');
const response = await this.got(`${this.platformUrl}/api/v1/auth/findSession`, {
headers: {
Accept: 'application/json',
Authorization: `Bearer ${accessToken}`
},
responseType: 'json',
retry: 0
});
return response.body?.result?.orgs?.length > 1;
} catch (err) {
warn(`Failed to find session: ${err.message}`);
return false;
}
}

/* istanbul ignore next */
/**
* This property is meant to be overridden by authenticator implementations.
Expand Down
2 changes: 1 addition & 1 deletion packages/axway-cli-auth/src/auth/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ team to use for "axway" commands.`;
or
${style.highlight('axway auth login --client-id <id> --client-secret <key> --username <email>')}

To set your Platform Tooling password, visit https://platform.axway.com/#/user/credentials`;
To set your Platform Tooling password, visit https://platform.axway.com/user/credentials`;
}
},
options: [
Expand Down
2 changes: 1 addition & 1 deletion packages/axway-cli-oum/src/org/idp.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export default {
throw new Error('Managing identity provider settings requires a web browser and is unsupported in headless environments');
}

const url = `${sdk.platformUrl}#/org/${org.id}/settings/idp`;
const url = `${sdk.platformUrl}/org/${org.id}/settings/idp`;
console.log(`Opening web browser to ${highlight(url)}`);
await open(url);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/axway-cli-oum/src/user/credentials.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default {
throw new Error('Changing your login credentials requires a web browser and is unsupported in headless environments');
}
if (sdk !== null) {
const url = `${sdk.platformUrl}#/user/credentials`;
const url = `${sdk.platformUrl}/user/credentials`;
console.log(`Opening web browser to ${highlight(url)}`);
await open(url);
}
Expand Down
Loading