Skip to content

Commit ad256df

Browse files
vishalshrm539Vishal
andauthored
Upgrade pega/auth, fixed a condition, & have added the changes made as part of US-637974 (#235)
Co-authored-by: Vishal <[email protected]>
1 parent 79fb57b commit ad256df

File tree

5 files changed

+43
-134
lines changed

5 files changed

+43
-134
lines changed

package-lock.json

Lines changed: 29 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
"@angular/platform-browser-dynamic": "^18.2.12",
6969
"@angular/router": "^18.2.12",
7070
"@danielmoncada/angular-datetime-picker": "^18.1.0",
71-
"@pega/auth": "~0.2.17",
71+
"@pega/auth": "~0.2.19",
7272
"@tinymce/tinymce-angular": "^8.0.1",
7373
"core-js": "^3.39.0",
7474
"dayjs": "^1.11.13",

packages/angular-sdk-components/src/lib/_components/template/list-view/list-view.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -961,7 +961,7 @@ export class ListViewComponent implements OnInit, OnDestroy {
961961

962962
filterDataWithDate(item, filterObj, filterValue) {
963963
let bKeep;
964-
let value = item[filterObj.ref] != null ?? item[filterObj.ref] != '' ? getSeconds(item[filterObj.ref]) : null;
964+
let value = item[filterObj.ref] != null || item[filterObj.ref] != '' ? getSeconds(item[filterObj.ref]) : null;
965965
filterValue = filterObj.containsFilterValue != null && filterObj.containsFilterValue != '' ? getSeconds(filterObj.containsFilterValue) : null;
966966

967967
switch (filterObj.containsFilter) {

packages/angular-sdk-components/src/lib/_components/template/simple-table-manual/helpers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ export const createMetaForTable = (fields, renderMode) => {
190190

191191
export const filterDataByDate = (item, filterObj) => {
192192
let bKeep;
193-
let value = item[filterObj.ref] != null ?? item[filterObj.ref] != '' ? getSeconds(item[filterObj.ref]) : null;
193+
let value = item[filterObj.ref] != null || item[filterObj.ref] != '' ? getSeconds(item[filterObj.ref]) : null;
194194
let filterValue = filterObj.containsFilterValue != null && filterObj.containsFilterValue != '' ? getSeconds(filterObj.containsFilterValue) : null;
195195

196196
switch (filterObj.containsFilter) {

projects/angular-test-app/src/app/_samples/embedded/mc-nav/mc-nav.component.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { MatIconModule } from '@angular/material/icon';
66
import { MatToolbarModule } from '@angular/material/toolbar';
77
import { MatProgressSpinnerModule } from '@angular/material/progress-spinner';
88
import { Subscription } from 'rxjs';
9-
import { loginIfNecessary, logout, sdkSetAuthHeader } from '@pega/auth/lib/sdk-auth-manager';
9+
import { loginIfNecessary, logout, sdkSetAuthHeader, sdkSetCustomTokenParamsCB } from '@pega/auth/lib/sdk-auth-manager';
1010

1111
import { ProgressSpinnerService } from '../../../../../../../packages/angular-sdk-components/src/lib/_messages/progress-spinner.service';
1212
import { UpdateWorklistService } from '../../../../../../../packages/angular-sdk-components/src/lib/_messages/update-worklist.service';
@@ -89,13 +89,13 @@ export class MCNavComponent implements OnInit, OnDestroy {
8989

9090
const sdkConfigAuth = await this.scservice.getSdkConfigAuth();
9191

92-
if (!sdkConfigAuth.mashupClientId && sdkConfigAuth.customAuthType === 'Basic') {
92+
if ((sdkConfigAuth.mashupGrantType === 'none' || !sdkConfigAuth.mashupClientId) && sdkConfigAuth.customAuthType === 'Basic') {
9393
// Service package to use custom auth with Basic
9494
const sB64 = window.btoa(`${sdkConfigAuth.mashupUserIdentifier}:${window.atob(sdkConfigAuth.mashupPassword)}`);
9595
sdkSetAuthHeader(`Basic ${sB64}`);
9696
}
9797

98-
if (!sdkConfigAuth.mashupClientId && sdkConfigAuth.customAuthType === 'BasicTO') {
98+
if ((sdkConfigAuth.mashupGrantType === 'none' || !sdkConfigAuth.mashupClientId) && sdkConfigAuth.customAuthType === 'BasicTO') {
9999
const now = new Date();
100100
const expTime = new Date(now.getTime() + 5 * 60 * 1000);
101101
let sISOTime = `${expTime.toISOString().split('.')[0]}Z`;
@@ -106,6 +106,14 @@ export class MCNavComponent implements OnInit, OnDestroy {
106106
sdkSetAuthHeader(`Basic ${sB64}`);
107107
}
108108

109+
if (sdkConfigAuth.mashupGrantType === 'customBearer' && sdkConfigAuth.customAuthType === 'CustomIdentifier') {
110+
// Use custom bearer with specific custom parameter to set the desired operator via
111+
// a userIdentifier property. (Caution: highly insecure...being used for simple demonstration)
112+
sdkSetCustomTokenParamsCB(() => {
113+
return { userIdentifier: sdkConfigAuth.mashupUserIdentifier };
114+
});
115+
}
116+
109117
// Login if needed, without doing an initial main window redirect
110118
// eslint-disable-next-line no-restricted-globals
111119
const sAppName = location.pathname.substring(location.pathname.indexOf('/') + 1);

0 commit comments

Comments
 (0)