From 401f7edf9f70032b37da86d6494293c4525febef Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Fernadez Date: Mon, 4 Nov 2024 16:28:02 -0600 Subject: [PATCH 1/3] 9422-email-domains-interstitial-oauth --- .../form-authorize.component.ts | 1 - .../pages/authorize/authorize.component.ts | 28 +++++++++++++++-- .../interstitials.service.spec.ts | 16 ++++++++++ .../interstitials/interstitials.service.ts | 31 +++++++++++++++++++ .../share-emails-domains.component.ts | 1 - 5 files changed, 72 insertions(+), 5 deletions(-) create mode 100644 src/app/cdk/interstitials/interstitials.service.spec.ts create mode 100644 src/app/cdk/interstitials/interstitials.service.ts diff --git a/src/app/authorize/components/form-authorize/form-authorize.component.ts b/src/app/authorize/components/form-authorize/form-authorize.component.ts index fb6c91e50..e64cc57cd 100644 --- a/src/app/authorize/components/form-authorize/form-authorize.component.ts +++ b/src/app/authorize/components/form-authorize/form-authorize.component.ts @@ -86,7 +86,6 @@ export class FormAuthorizeComponent implements OnInit, OnDestroy { this.loadingTrustedIndividuals = false this.oauthRequest = userInfo.oauthSession this.organizationName.emit(this.oauthRequest.clientName) - console.log('this ', this.oauthRequest.clientName) if (userInfo.loggedIn) { this.userName = userInfo.displayName this.orcidUrl = userInfo.effectiveOrcidUrl diff --git a/src/app/authorize/pages/authorize/authorize.component.ts b/src/app/authorize/pages/authorize/authorize.component.ts index 77cd7ada3..c127b6a0a 100644 --- a/src/app/authorize/pages/authorize/authorize.component.ts +++ b/src/app/authorize/pages/authorize/authorize.component.ts @@ -1,6 +1,7 @@ import { Component, Inject } from '@angular/core' import { cloneDeep } from 'lodash' import { first, take, tap } from 'rxjs/operators' +import { InterstitialsService } from 'src/app/cdk/interstitials/interstitials.service' import { PlatformInfo, PlatformInfoService } from 'src/app/cdk/platform-info' import { WINDOW } from 'src/app/cdk/window' import { UserService } from 'src/app/core' @@ -24,13 +25,17 @@ export class AuthorizeComponent { userHasPrivateDomains = false oauthDomainsInterstitialEnabled: boolean organizationName: string + domainInterstitialHasBeenViewed: boolean + userIsNotImpersonating: boolean constructor( _user: UserService, private _platformInfo: PlatformInfoService, private _recordEmails: RecordEmailsService, private _togglz: TogglzService, - @Inject(WINDOW) private window: Window + private _interstitials: InterstitialsService, + @Inject(WINDOW) private window: Window, + private _userInfo: UserService ) { _user.getUserSession().subscribe((session) => { if (session.oauthSession && session.oauthSession.error) { @@ -45,6 +50,17 @@ export class AuthorizeComponent { } ngOnInit() { + this._userInfo.getUserSession().subscribe((userInfo) => { + this.userIsNotImpersonating = + userInfo.userInfo.REAL_USER_ORCID === + userInfo.userInfo.EFFECTIVE_USER_ORCID + }) + this._interstitials + .getInterstitialsViewed('OAUTH_DOMAIN_INTERSTITIAL') + .subscribe((value) => { + return (this.domainInterstitialHasBeenViewed = value) + }) + this._togglz .getStateOf('OAUTH_DOMAINS_INTERSTITIAL') .pipe(take(1)) @@ -68,14 +84,20 @@ export class AuthorizeComponent { } handleRedirect(url: string) { + this.redirectUrl = url + if ( url && this.userHasPrivateDomains && - this.oauthDomainsInterstitialEnabled + this.oauthDomainsInterstitialEnabled && + !this.domainInterstitialHasBeenViewed && + this.userIsNotImpersonating ) { - this.redirectUrl = url this.showAuthorizationComponent = false this.showInterstital = true + this._interstitials + .setInterstitialsViewed('OAUTH_DOMAIN_INTERSTITIAL') + .subscribe() } else { this.finishRedirect() } diff --git a/src/app/cdk/interstitials/interstitials.service.spec.ts b/src/app/cdk/interstitials/interstitials.service.spec.ts new file mode 100644 index 000000000..4f647fd98 --- /dev/null +++ b/src/app/cdk/interstitials/interstitials.service.spec.ts @@ -0,0 +1,16 @@ +import { TestBed } from '@angular/core/testing'; + +import { InterstitialsService } from './interstitials.service'; + +describe('InterstitialsService', () => { + let service: InterstitialsService; + + beforeEach(() => { + TestBed.configureTestingModule({}); + service = TestBed.inject(InterstitialsService); + }); + + it('should be created', () => { + expect(service).toBeTruthy(); + }); +}); diff --git a/src/app/cdk/interstitials/interstitials.service.ts b/src/app/cdk/interstitials/interstitials.service.ts new file mode 100644 index 000000000..831f4ff16 --- /dev/null +++ b/src/app/cdk/interstitials/interstitials.service.ts @@ -0,0 +1,31 @@ +import { Injectable } from '@angular/core' +import { userInfo } from 'os' +import { map } from 'rxjs/operators' +import { UserService } from 'src/app/core' +type Interstitials = 'OAUTH_DOMAIN_INTERSTITIAL' | 'SIGN_IN_DOMAIN_INTERSTITIAL' + +@Injectable({ + providedIn: 'root', +}) +export class InterstitialsService { + constructor(private _userInfo: UserService) {} + + setInterstitialsViewed(interstitial: Interstitials) { + return this._userInfo.getUserSession().pipe( + map((userInfo) => { + const effectiveUser = userInfo.userInfo.EFFECTIVE_USER_ORCID + localStorage.setItem(effectiveUser + '_' + interstitial, 'true') + }) + ) + } + getInterstitialsViewed(interstitial: Interstitials) { + return this._userInfo.getUserSession().pipe( + map((userInfo) => { + const effectiveUser = userInfo.userInfo.EFFECTIVE_USER_ORCID + return ( + localStorage.getItem(effectiveUser + '_' + interstitial) === 'true' + ) + }) + ) + } +} diff --git a/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.ts b/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.ts index 526713901..1e5060cf1 100644 --- a/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.ts +++ b/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.ts @@ -30,7 +30,6 @@ export class ShareEmailsDomainsComponent { @Output() finish = new EventEmitter() ngOnInit() { - console.log(this.organizationName) this.userPrivateDomains = this.getTop3MostRecentPrivateDomains( this.userEmailsJson ) From 26a4ea542c2109fee8405004ce54e80f83fdf124 Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Fernadez Date: Mon, 4 Nov 2024 16:31:47 -0600 Subject: [PATCH 2/3] 9422-email-domains-interstitial-oauth --- .../interstitials.service.spec.ts | 26 ++++++++++++------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/src/app/cdk/interstitials/interstitials.service.spec.ts b/src/app/cdk/interstitials/interstitials.service.spec.ts index 4f647fd98..a626b60b8 100644 --- a/src/app/cdk/interstitials/interstitials.service.spec.ts +++ b/src/app/cdk/interstitials/interstitials.service.spec.ts @@ -1,16 +1,24 @@ -import { TestBed } from '@angular/core/testing'; +import { TestBed } from '@angular/core/testing' -import { InterstitialsService } from './interstitials.service'; +import { InterstitialsService } from './interstitials.service' +import { UserService } from 'src/app/core' describe('InterstitialsService', () => { - let service: InterstitialsService; + let service: InterstitialsService beforeEach(() => { - TestBed.configureTestingModule({}); - service = TestBed.inject(InterstitialsService); - }); + TestBed.configureTestingModule({ + providers: [ + { + provide: UserService, + useValue: {}, + }, + ], + }) + service = TestBed.inject(InterstitialsService) + }) it('should be created', () => { - expect(service).toBeTruthy(); - }); -}); + expect(service).toBeTruthy() + }) +}) From 84c9d2152d68ac182dd9c4292a356b9bfc60cb2f Mon Sep 17 00:00:00 2001 From: Leonardo Mendoza Fernadez Date: Mon, 4 Nov 2024 16:34:29 -0600 Subject: [PATCH 3/3] 9422-email-domains-interstitial-oauth --- guides/example-tx-config.yml | 2 +- src/app/authorize/authorize.module.ts | 2 +- .../info-panel/info-panel.component.spec.ts | 26 +++++++++---------- .../info-panel/info-panel.component.ts | 11 ++++---- .../share-emails-domains.component.scss | 5 +--- ...e-emails-domains.component.scss-theme.scss | 4 +-- .../share-emails-domains.component.ts | 5 ++-- .../cdk/platform-info/browserlist.regexp.ts | 3 ++- 8 files changed, 27 insertions(+), 31 deletions(-) diff --git a/guides/example-tx-config.yml b/guides/example-tx-config.yml index 364de2ee1..a44b1edf8 100644 --- a/guides/example-tx-config.yml +++ b/guides/example-tx-config.yml @@ -199,4 +199,4 @@ filters: source_language: en source_file: src/locale/properties/interstitials/interstitials.en.properties # path expression to translation files, must contain placeholder - translation_files_expression: src/locale/properties/interstitials/interstitials..properties \ No newline at end of file + translation_files_expression: src/locale/properties/interstitials/interstitials..properties diff --git a/src/app/authorize/authorize.module.ts b/src/app/authorize/authorize.module.ts index e5a8cd822..4dbdc64f2 100644 --- a/src/app/authorize/authorize.module.ts +++ b/src/app/authorize/authorize.module.ts @@ -37,7 +37,7 @@ import { InterstitialsModule } from '../cdk/interstitials/interstitials.module' TrustedIndividualsDropdownModule, InfoDropDownModule, MatProgressBarModule, - InterstitialsModule + InterstitialsModule, ], }) export class AuthorizeModule {} diff --git a/src/app/cdk/info-panel/info-panel/info-panel.component.spec.ts b/src/app/cdk/info-panel/info-panel/info-panel.component.spec.ts index 1cfc9e243..b2e99d7da 100644 --- a/src/app/cdk/info-panel/info-panel/info-panel.component.spec.ts +++ b/src/app/cdk/info-panel/info-panel/info-panel.component.spec.ts @@ -1,21 +1,21 @@ -import { ComponentFixture, TestBed } from '@angular/core/testing'; +import { ComponentFixture, TestBed } from '@angular/core/testing' -import { InfoPanelComponent } from './info-panel.component'; +import { InfoPanelComponent } from './info-panel.component' describe('InfoPanelComponent', () => { - let component: InfoPanelComponent; - let fixture: ComponentFixture; + let component: InfoPanelComponent + let fixture: ComponentFixture beforeEach(() => { TestBed.configureTestingModule({ - declarations: [InfoPanelComponent] - }); - fixture = TestBed.createComponent(InfoPanelComponent); - component = fixture.componentInstance; - fixture.detectChanges(); - }); + declarations: [InfoPanelComponent], + }) + fixture = TestBed.createComponent(InfoPanelComponent) + component = fixture.componentInstance + fixture.detectChanges() + }) it('should create', () => { - expect(component).toBeTruthy(); - }); -}); + expect(component).toBeTruthy() + }) +}) diff --git a/src/app/cdk/info-panel/info-panel/info-panel.component.ts b/src/app/cdk/info-panel/info-panel/info-panel.component.ts index cff766a00..7fd1c7178 100644 --- a/src/app/cdk/info-panel/info-panel/info-panel.component.ts +++ b/src/app/cdk/info-panel/info-panel/info-panel.component.ts @@ -1,10 +1,11 @@ -import { Component } from '@angular/core'; +import { Component } from '@angular/core' @Component({ selector: 'app-info-panel', templateUrl: './info-panel.component.html', - styleUrls: ['./info-panel.component.scss', './info-panel.component.scss-theme.scss'] + styleUrls: [ + './info-panel.component.scss', + './info-panel.component.scss-theme.scss', + ], }) -export class InfoPanelComponent { - -} +export class InfoPanelComponent {} diff --git a/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.scss b/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.scss index e02db7e34..694925408 100644 --- a/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.scss +++ b/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.scss @@ -1,12 +1,10 @@ @import '../../../../assets/scss/orcid.spacing.scss'; - h2 { margin-top: 16px; margin-bottom: 16px; - } -.published-email-container{ +.published-email-container { display: flex; align-items: center; } @@ -65,7 +63,6 @@ mat-divider { margin-bottom: 16px; } - mat-divider.last { margin-top: 32px; margin-bottom: 32px; diff --git a/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.scss-theme.scss b/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.scss-theme.scss index 150c755f1..d6828643e 100644 --- a/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.scss-theme.scss +++ b/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.scss-theme.scss @@ -12,13 +12,11 @@ background-color: mat.get-color-from-palette($primary, 700); } - ::ng-deep{ + ::ng-deep { .mat-divider.green-divider { border: solid 1px mat.get-color-from-palette($foreground, brand-primary); } } } - - @include theme($orcid-app-theme); diff --git a/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.ts b/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.ts index 1e5060cf1..5f8245ec1 100644 --- a/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.ts +++ b/src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component.ts @@ -60,9 +60,8 @@ export class ShareEmailsDomainsComponent { accept(answear: boolean) { this.domainToMakePublic = this.form.value.items - .filter((item) => item.selected) - .map((item) => item.email) - + .filter((item) => item.selected) + .map((item) => item.email) if (answear && this.domainToMakePublic.length > 0) { this.userEmailsJson.emailDomains.forEach((domain) => { diff --git a/src/app/cdk/platform-info/browserlist.regexp.ts b/src/app/cdk/platform-info/browserlist.regexp.ts index bf8c4aa5c..545a90290 100644 --- a/src/app/cdk/platform-info/browserlist.regexp.ts +++ b/src/app/cdk/platform-info/browserlist.regexp.ts @@ -1,2 +1,3 @@ // tslint:disable-next-line: max-line-length -export const BROWSERLIST_REGEXP = /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/ +export const BROWSERLIST_REGEXP = + /((CPU[ +]OS|iPhone[ +]OS|CPU[ +]iPhone|CPU IPhone OS)[ +]+(13[_.]4|13[_.]([5-9]|\d{2,})|13[_.]7|13[_.]([8-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})[_.]\d+|14[_.]0|14[_.]([1-9]|\d{2,})|14[_.]4|14[_.]([5-9]|\d{2,})|14[_.]8|14[_.](9|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})[_.]\d+|15[_.]0|15[_.]([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})[_.]\d+|16[_.]0|16[_.]([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})[_.]\d+|17[_.]0|17[_.]([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})[_.]\d+)(?:[_.]\d+)?)|((?:Chrome).*OPR\/(74|(7[5-9]|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Edge\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))(?:\.\d+)?)|((Chromium|Chrome)\/(80|(8[1-9]|9\d|\d{3,})|83|(8[4-9]|9\d|\d{3,}))\.\d+(?:\.\d+)?)|(Version\/(13\.1|13\.([2-9]|\d{2,})|(1[4-9]|[2-9]\d|\d{3,})\.\d+|14\.0|14\.([1-9]|\d{2,})|(1[5-9]|[2-9]\d|\d{3,})\.\d+|15\.0|15\.([1-9]|\d{2,})|(1[6-9]|[2-9]\d|\d{3,})\.\d+|16\.0|16\.([1-9]|\d{2,})|(1[7-9]|[2-9]\d|\d{3,})\.\d+|17\.0|17\.([1-9]|\d{2,})|(1[8-9]|[2-9]\d|\d{3,})\.\d+)(?:\.\d+)? Safari\/)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+\.\d+)|(Firefox\/(78|(79|[8-9]\d|\d{3,}))\.\d+(pre|[ab]\d+[a-z]*)?)/