Skip to content

Commit

Permalink
Merge pull request #346 from sasjs/issue-345
Browse files Browse the repository at this point in the history
fix: clientID should default to clientID1 for serverType sasjs
  • Loading branch information
sabhas authored Sep 5, 2022
2 parents 34326ae + 2fb0e19 commit 36fcb86
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 4 additions & 1 deletion src/commands/execute-code/internal/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ export const getAuthConfig = async (
debug: true
})

const clientId = await getClientId()
const defaultClientID =
target.serverType === ServerType.Sasjs ? 'clientID1' : undefined

const clientId = await getClientId(defaultClientID)
let clientSecret = ''
if (target.serverType === ServerType.SasViya) {
clientSecret = await getClientSecret()
Expand Down
5 changes: 4 additions & 1 deletion src/utils/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,10 @@ export const authenticateTarget = async (
serverType: targetJson.serverType
})

const clientId = await getClientId()
const defaultClientID =
targetJson.serverType === ServerType.Sasjs ? 'clientID1' : undefined

const clientId = await getClientId(defaultClientID)
const clientSecret =
targetJson.serverType === ServerType.SasViya ? await getClientSecret() : ''

Expand Down
10 changes: 7 additions & 3 deletions src/utils/input.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,12 @@ export const getServerType = async () => {
return serverType
}

export const getClientId = async () => {
export const getClientId = async (defaultClientID?: string) => {
const clientId = await getTextInput(
'Please enter your Client ID',
(value: string) => (value ? null : 'Client ID can not be empty')
(value: string) => (value ? null : 'Client ID can not be empty'),
false,
defaultClientID
)

return clientId
Expand Down Expand Up @@ -101,9 +103,11 @@ export const getPassword = async () => {
export const getTextInput = async (
placeHolder: string,
validator: (value: string) => string | null,
password: boolean = false
password: boolean = false,
value?: string
) => {
const input = await window.showInputBox({
value,
placeHolder,
ignoreFocusOut: true,
password,
Expand Down

0 comments on commit 36fcb86

Please sign in to comment.