Skip to content

Commit

Permalink
Merge pull request #63 from bcgov/fix/uniform-login
Browse files Browse the repository at this point in the history
Check uniform response for idir field
  • Loading branch information
hannah-macdonald1 authored Jan 7, 2025
2 parents 953fcaa + be720b5 commit 886ec9b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
17 changes: 13 additions & 4 deletions src/common/guards/auth/auth.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,13 @@ describe('AuthService', () => {
const spy = jest.spyOn(httpService, 'get').mockReturnValueOnce(
of({
data: {
[configService.get(`upstreamAuth.${validRecordType}.idirField`)]:
testIdir,
items: [
{
[configService.get(
`upstreamAuth.${validRecordType}.idirField`,
)]: testIdir,
},
],
},
headers: {},
config: {
Expand Down Expand Up @@ -174,8 +179,12 @@ describe('AuthService', () => {
const spy = jest.spyOn(httpService, 'get').mockReturnValueOnce(
of({
data: {
[configService.get(`upstreamAuth.${recordType}.idirField`)]:
testIdir,
items: [
{
[configService.get(`upstreamAuth.${recordType}.idirField`)]:
testIdir,
},
],
},
headers: {},
config: {
Expand Down
8 changes: 5 additions & 3 deletions src/common/guards/auth/auth.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {
CHILD_LINKS,
CONTENT_TYPE,
idName,
UNIFORM_RESPONSE,
uniformResponseParamName,
VIEW_MODE,
} from '../../../common/constants/parameter-constants';
import { firstValueFrom } from 'rxjs';
Expand Down Expand Up @@ -87,6 +89,7 @@ export class AuthService {
const params = {
ViewMode: VIEW_MODE,
ChildLinks: CHILD_LINKS,
[uniformResponseParamName]: UNIFORM_RESPONSE,
};
if (
(workspace = this.configService.get(
Expand All @@ -112,13 +115,12 @@ export class AuthService {
throw new Error('Upstream auth failed');
}
headers['Authorization'] = token;
this.logger.log(url, params, headers);
response = await firstValueFrom(
this.httpService.get(url, { params, headers }),
);
this.logger.log(response);

const idir =
response.data[
response.data['items'][0][
this.configService.get<string>(`upstreamAuth.${recordType}.idirField`)
];
if (idir === undefined) {
Expand Down

0 comments on commit 886ec9b

Please sign in to comment.