-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2402 from ORCID/lmendoza/singin-interstitial
9499-email-domains-interstitial-registry-sign-in
- Loading branch information
Showing
20 changed files
with
379 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,7 @@ | |
border: solid 2px; | ||
border-radius: 4px; | ||
display: flex; | ||
gap: 16px; | ||
|
||
p { | ||
margin: 0; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
src/app/cdk/interstitials/share-emails-domains/share-emails-domains-dialog.component.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
mat-card-header.authorize-header { | ||
mat-card-title { | ||
margin: 0 0 32px 0 !important; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
} | ||
} | ||
:host { | ||
padding: 48px; | ||
display: block; | ||
} |
52 changes: 52 additions & 0 deletions
52
src/app/cdk/interstitials/share-emails-domains/share-emails-domains-dialog.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { Component, EventEmitter, Inject, Input, Output } from '@angular/core' | ||
import { PlatformInfoService } from '../../platform-info' | ||
import { AssertionVisibilityString, EmailsEndpoint } from 'src/app/types' | ||
import { FormBuilder, FormControl, FormGroup } from '@angular/forms' | ||
import { RecordEmailsService } from 'src/app/core/record-emails/record-emails.service' | ||
import { error } from 'console' | ||
import { WINDOW } from '../../window' | ||
import { | ||
MAT_LEGACY_DIALOG_DATA, | ||
MatLegacyDialogRef, | ||
MatLegacyDialogState, | ||
} from '@angular/material/legacy-dialog' | ||
import { ShareEmailsDomainsComponent } from './share-emails-domains.component' | ||
|
||
export type ShareEmailsDomainsComponentDialogInput = { | ||
userEmailsJson: EmailsEndpoint | ||
organizationName?: string | ||
} | ||
|
||
@Component({ | ||
templateUrl: './share-emails-domains.component.html', | ||
styleUrls: [ | ||
'./share-emails-domains.component.scss', | ||
'./share-emails-domains.component.scss-theme.scss', | ||
'./share-emails-domains-dialog.component.scss', | ||
], | ||
}) | ||
export class ShareEmailsDomainsDialogComponent extends ShareEmailsDomainsComponent { | ||
constructor( | ||
platformInfo: PlatformInfoService, | ||
fb: FormBuilder, | ||
recordEmailsService: RecordEmailsService, | ||
@Inject(WINDOW) window: Window, | ||
@Inject(MAT_LEGACY_DIALOG_DATA) | ||
public data: ShareEmailsDomainsComponentDialogInput, | ||
public dialogRef: MatLegacyDialogRef<ShareEmailsDomainsDialogComponent> | ||
) { | ||
super(platformInfo, fb, recordEmailsService, window) | ||
if (this.data) { | ||
this.userEmailsJson = this.data.userEmailsJson | ||
this.organizationName = this.data.organizationName | ||
} | ||
} | ||
|
||
override finishIntertsitial(emails?: string[]) { | ||
this.dialogRef.close(emails) | ||
} | ||
|
||
override afterEmailUpdates(emails: string[]) { | ||
this.finishIntertsitial(emails) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,2 @@ | ||
// 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]*)?)/ |
42 changes: 28 additions & 14 deletions
42
src/app/cdk/warning-message/warning-message/warning-message.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,33 @@ | ||
<div | ||
class="container-text-and-icon" | ||
class="wrapper" | ||
[ngClass]="{ | ||
'orc-font-body-small': !isMobile, | ||
'orc-font-small-print': isMobile | ||
}" | ||
'warning-message': type === 'warning', | ||
'success-message': type === 'success', | ||
}" | ||
> | ||
<div class="col"> | ||
<mat-icon>{{ icon }}</mat-icon> | ||
</div> | ||
<div class="text-container"> | ||
<strong> | ||
<ng-content select="[title]"> </ng-content> | ||
</strong> | ||
<p> | ||
<ng-content select="[content]"></ng-content> | ||
</p> | ||
<div | ||
class="container-text-and-icon" | ||
[ngClass]="{ | ||
'orc-font-body-small': !isMobile, | ||
'orc-font-small-print': isMobile | ||
}" | ||
> | ||
<div class="col"> | ||
<mat-icon | ||
[ngClass]="{ | ||
'material-icons-outlined' : type === 'success', | ||
}" | ||
> | ||
{{ icon }}</mat-icon | ||
> | ||
</div> | ||
<div class="text-container"> | ||
<strong> | ||
<ng-content select="[title]"> </ng-content> | ||
</strong> | ||
<p> | ||
<ng-content select="[content]"></ng-content> | ||
</p> | ||
</div> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
src/app/core/login-interstitials/login-interstitials.service.spec.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { TestBed } from '@angular/core/testing' | ||
|
||
import { LoginInterstitialsService } from './login-interstitials.service' | ||
import { MatLegacyDialog } from '@angular/material/legacy-dialog' | ||
import { InterstitialsService } from 'src/app/cdk/interstitials/interstitials.service' | ||
import { TogglzService } from '../togglz/togglz.service' | ||
import { NEVER } from 'rxjs' | ||
|
||
describe('LoginInterstitialsService', () => { | ||
let service: LoginInterstitialsService | ||
|
||
beforeEach(() => { | ||
TestBed.configureTestingModule({ | ||
providers: [ | ||
{ provide: MatLegacyDialog, useValue: {} }, | ||
{ | ||
provide: InterstitialsService, | ||
useValue: { getInterstitialsViewed: () => NEVER }, | ||
}, | ||
{ provide: TogglzService, useValue: { getStateOf: () => NEVER } }, | ||
], | ||
}) | ||
service = TestBed.inject(LoginInterstitialsService) | ||
}) | ||
|
||
it('should be created', () => { | ||
expect(service).toBeTruthy() | ||
}) | ||
}) |
84 changes: 84 additions & 0 deletions
84
src/app/core/login-interstitials/login-interstitials.service.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
import { Injectable } from '@angular/core' | ||
import { | ||
MatLegacyDialog as MatDialog, | ||
MatLegacyDialogState, | ||
} from '@angular/material/legacy-dialog' | ||
import { ShareEmailsDomainsComponent } from 'src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component' | ||
import { EmailsEndpoint } from 'src/app/types' | ||
import { UserRecord } from 'src/app/types/record.local' | ||
import { ShareEmailsDomainsComponentDialogInput } from 'src/app/cdk/interstitials/share-emails-domains/share-emails-domains.component' | ||
import { InterstitialsService } from 'src/app/cdk/interstitials/interstitials.service' | ||
import { Observable } from 'rxjs' | ||
import { ShareEmailsDomainsDialogComponent } from 'src/app/cdk/interstitials/share-emails-domains/share-emails-domains-dialog.component' | ||
import { TogglzService } from '../togglz/togglz.service' | ||
|
||
@Injectable({ | ||
providedIn: 'root', | ||
}) | ||
export class LoginInterstitialsService { | ||
alreadySawSignDomainInterstitial: boolean | ||
loginDomainsInterstitialEnabled: boolean | ||
alreadyCheckLoginInterstitials: boolean | ||
constructor( | ||
private _matDialog: MatDialog, | ||
private interstitialService: InterstitialsService, | ||
private toggleService: TogglzService | ||
) { | ||
this.interstitialService | ||
.getInterstitialsViewed('SIGN_IN_DOMAIN_INTERSTITIAL') | ||
.subscribe((viewed) => { | ||
this.alreadySawSignDomainInterstitial = viewed | ||
}) | ||
this.toggleService | ||
.getStateOf('LOGIN_DOMAINS_INTERSTITIAL') | ||
.subscribe((state) => { | ||
this.loginDomainsInterstitialEnabled = state | ||
}) | ||
} | ||
|
||
checkLoginInterstitials(userRecord: UserRecord): Observable<string[]> | void { | ||
if ( | ||
userRecord?.userInfo && | ||
userRecord?.emails?.emailDomains && | ||
!this.alreadyCheckLoginInterstitials | ||
) { | ||
this.alreadyCheckLoginInterstitials = true | ||
const isNotImpersonating = | ||
userRecord.userInfo.REAL_USER_ORCID === | ||
userRecord.userInfo.EFFECTIVE_USER_ORCID | ||
|
||
if ( | ||
isNotImpersonating && | ||
!this.userHasPublicDomains(userRecord.emails) && | ||
this.userHasPrivateDomains(userRecord.emails) && | ||
this.loginDomainsInterstitialEnabled && | ||
!this.alreadySawSignDomainInterstitial | ||
) { | ||
this.alreadySawSignDomainInterstitial = true | ||
this.interstitialService | ||
.setInterstitialsViewed('SIGN_IN_DOMAIN_INTERSTITIAL') | ||
.subscribe() | ||
const data: ShareEmailsDomainsComponentDialogInput = { | ||
userEmailsJson: userRecord.emails, | ||
} | ||
|
||
const dialog = this._matDialog.open(ShareEmailsDomainsDialogComponent, { | ||
data, | ||
width: '580px', | ||
disableClose: true, | ||
autoFocus: false, | ||
restoreFocus: false, | ||
}) | ||
return dialog.afterClosed() | ||
} | ||
} | ||
} | ||
|
||
userHasPublicDomains(value: EmailsEndpoint): any { | ||
return !!value.emailDomains.find((domain) => domain.visibility === 'PUBLIC') | ||
} | ||
|
||
userHasPrivateDomains(value: EmailsEndpoint): boolean { | ||
return !!value.emailDomains.find((domain) => domain.visibility !== 'PUBLIC') | ||
} | ||
} |
Oops, something went wrong.