Skip to content

Commit

Permalink
chore: code refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
pviti committed Dec 7, 2023
1 parent 0415b76 commit 59def51
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/commands/applications/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,11 @@ const getApplicationInfo = async (auth: AppAuth, accessToken: string): Promise<A

const provisioning = clApplication.isProvisioningApp(auth)

let org, app
let org, app, scope
if (provisioning) {
org = { name: 'Provisioning API', slug: 'provisioning' }
app = { name: 'Provisioning App' }
scope: tokenInfo.scope
} else { // core
const cl = commercelayer({ organization: auth.slug || '', domain: auth.domain, accessToken })
// Organization info
Expand All @@ -199,6 +200,7 @@ const getApplicationInfo = async (auth: AppAuth, accessToken: string): Promise<A
app = await cl.application.retrieve().catch(() => {
throw new Error(`This application cannot access the ${clColor.italic('Application')} resource`)
})
scope = auth.scope
}

const mode: ApiMode = tokenInfo.test ? 'test' : 'live'
Expand All @@ -213,7 +215,7 @@ const getApplicationInfo = async (auth: AppAuth, accessToken: string): Promise<A
baseUrl: clApi.baseURL(auth.slug, auth.domain, provisioning),
id: tokenInfo.application.id,
alias: '',
scope: tokenInfo.scope || auth.scope
scope
})

// if (Array.isArray(appInfo.scope) && (appInfo.scope.length === 0)) appInfo.scope = undefined
Expand Down

0 comments on commit 59def51

Please sign in to comment.