1
0
mirror of https://github.com/sasjs/adapter.git synced 2025-12-11 01:14:36 +00:00

fix: deprecating sasjs client id

This commit is contained in:
2022-05-09 13:26:17 +02:00
parent 72ed5e3fab
commit c243f25477
6 changed files with 12 additions and 30 deletions

View File

@@ -598,7 +598,7 @@ export default class SASjs {
'A username, password and clientId are required when using the default login mechanism with server type SASJS.'
)
return this.authManager!.logInSasjs(username, password, clientId)
return this.authManager!.logInSasjs(username, password)
}
return this.authManager!.logIn(username, password)

View File

@@ -104,7 +104,7 @@ export class SASjsApiClient {
clientId: string,
authCode: string
): Promise<SASjsAuthResponse> {
return getAccessTokenForSasjs(this.requestClient, clientId, authCode)
return getAccessTokenForSasjs(this.requestClient, authCode)
}
/**
@@ -126,7 +126,7 @@ export class SASjsApiClient {
password: string,
clientId: string
) {
return getAuthCodeForSasjs(this.requestClient, username, password, clientId)
return getAuthCodeForSasjs(this.requestClient, username, password)
}
}

View File

@@ -92,14 +92,9 @@ export class AuthManager {
*/
public async logInSasjs(
username: string,
password: string,
clientId: string
password: string
): Promise<LoginResult> {
const isLoggedIn = await this.sendLoginRequestSasjs(
username,
password,
clientId
)
const isLoggedIn = await this.sendLoginRequestSasjs(username, password)
.then((res) => {
this.userName = username
this.requestClient.saveLocalStorageToken(
@@ -215,18 +210,13 @@ export class AuthManager {
return loginResponse
}
private async sendLoginRequestSasjs(
username: string,
password: string,
clientId: string
) {
private async sendLoginRequestSasjs(username: string, password: string) {
const authCode = await getAuthCodeForSasjs(
this.requestClient,
username,
password,
clientId
password
)
return getAccessTokenForSasjs(this.requestClient, clientId, authCode)
return getAccessTokenForSasjs(this.requestClient, authCode)
}
/**
* Checks whether a session is active, or login is required.

View File

@@ -9,12 +9,10 @@ import { RequestClient } from '../request/RequestClient'
*/
export async function getAccessTokenForSasjs(
requestClient: RequestClient,
clientId: string,
authCode: string
) {
const url = '/SASjsApi/auth/token'
const data = {
clientId,
code: authCode
}

View File

@@ -11,11 +11,10 @@ import { RequestClient } from '../request/RequestClient'
export const getAuthCodeForSasjs = async (
requestClient: RequestClient,
username: string,
password: string,
clientId: string
password: string
) => {
const url = '/SASjsApi/auth/authorize'
const data = { username, password, clientId }
const data = { username, password }
const { code: authCode } = await requestClient
.post<{ code: string }>(url, data, undefined)

View File

@@ -22,15 +22,11 @@ describe('getAccessTokenForSasjs', () => {
Promise.resolve({ result: mockSasjsAuthResponse, etag: '' })
)
await getAccessTokenForSasjs(
requestClient,
authConfig.client,
authConfig.refresh_token
)
await getAccessTokenForSasjs(requestClient, authConfig.refresh_token)
expect(requestClient.post).toHaveBeenCalledWith(
'/SASjsApi/auth/token',
{ clientId: authConfig.client, code: authConfig.refresh_token },
{ code: authConfig.refresh_token },
undefined
)
})
@@ -51,7 +47,6 @@ describe('getAccessTokenForSasjs', () => {
const error = await getAccessTokenForSasjs(
requestClient,
authConfig.client,
authConfig.refresh_token
).catch((e) => e)