Skip to content

Commit d8a7b5f

Browse files
authored
PD-5548 add 2fa creation dates (#2833)
Co-authored-by: andrej romanov <50377758+auumgn@users.noreply.github.com>
1 parent f5eb71d commit d8a7b5f

7 files changed

Lines changed: 40 additions & 16 deletions

src/app/account-settings/components/settings-security-two-factor-auth/settings-security-two-factor-auth.component.html

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
Two-factor authentication was not disabled
1212
</div>
1313
</app-alert-message>
14-
} @if (!twoFactorState) {
14+
} @if (!twoFactorInfo?.enabled) {
1515
<div class="two-factor-panel">
1616
<p class="two-factor-panel__copy" i18n="@@account.addExtraSecurity">
1717
Add extra security to your ORCID account by enabling two-factor
@@ -58,9 +58,14 @@ <h4 i18n="@@account.signInWith2FA">Sign in with 2FA</h4>
5858
check_circle
5959
</mat-icon>
6060
<div>
61-
<p class="two-factor-panel__requirement-title" i18n>
61+
<p class="two-factor-panel__requirement-title leading-5.25" i18n>
6262
Authentication app
6363
</p>
64+
<small>
65+
{{
66+
twoFactorInfo?.twoFactorCreationDate | monthDayYearDateToString
67+
}}
68+
</small>
6469
</div>
6570
</div>
6671
</section>
@@ -83,9 +88,14 @@ <h4 i18n="@@account.accountRecovery">Account recovery</h4>
8388
check_circle
8489
</mat-icon>
8590
<div>
86-
<p class="two-factor-panel__requirement-title" i18n>
91+
<p class="two-factor-panel__requirement-title leading-5.25" i18n>
8792
2FA recovery codes
8893
</p>
94+
<small class="leading-4.5">
95+
{{
96+
twoFactorInfo?.recoveryCodeCreationDate | monthDayYearDateToString
97+
}}
98+
</small>
8999
</div>
90100
</div>
91101
</section>

src/app/account-settings/components/settings-security-two-factor-auth/settings-security-two-factor-auth.component.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@
6868

6969
.two-factor-panel__requirement-icon {
7070
color: var(--orcid-color-brand-primary-dark, #7faa26);
71-
width: 24px;
72-
height: 24px;
71+
width: 25px;
72+
height: 25px;
7373
font-size: 24px;
7474
}
7575

src/app/account-settings/components/settings-security-two-factor-auth/settings-security-two-factor-auth.component.scss-theme.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
color: map-get($foreground, 'brand-primary-darkest');
1717
}
1818

19+
small {
20+
color: mat.m2-get-contrast-color-from-palette($primary, 200);
21+
}
22+
1923
.two-factor-panel__enable-button {
2024
color: $orcid-light-primary-text !important;
2125
background: $brand-secondary-dark !important;

src/app/account-settings/components/settings-security-two-factor-auth/settings-security-two-factor-auth.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
UntypedFormGroup,
1212
Validators,
1313
} from '@angular/forms'
14+
import { Status } from '../../../types/two-factor.endpoint'
1415

1516
@Component({
1617
selector: 'app-settings-security-two-factor-auth',
@@ -22,7 +23,7 @@ import {
2223
standalone: false,
2324
})
2425
export class SettingsSecurityTwoFactorAuthComponent implements OnInit {
25-
@Input() twoFactorState: boolean
26+
@Input() twoFactorInfo: Status | undefined
2627
@Output() twoFactorStateOutput = new EventEmitter<any>()
2728

2829
form: UntypedFormGroup
@@ -68,7 +69,9 @@ export class SettingsSecurityTwoFactorAuthComponent implements OnInit {
6869
.subscribe({
6970
next: (response: any) => {
7071
if (response.success) {
71-
this.twoFactorState = response.enabled
72+
if (this.twoFactorInfo) {
73+
this.twoFactorInfo.enabled = response.enabled
74+
}
7275
this.twoFactorStateOutput.emit(false)
7376
dialogRef.close(true)
7477
} else {
@@ -89,7 +92,7 @@ export class SettingsSecurityTwoFactorAuthComponent implements OnInit {
8992
}
9093

9194
twoFactor() {
92-
if (!this.twoFactorState) {
95+
if (!this.twoFactorInfo?.enabled) {
9396
this._router.navigate([ApplicationRoutes.twoFactorSetup])
9497
} else {
9598
this.cancel = false

src/app/account-settings/components/settings-security/settings-security.component.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ <h2 class="orc-font-body-large col" i18n="@@account.security">Security</h2>
99
[loading]="settingSecurityPasswordLoading"
1010
>
1111
<app-settings-security-password
12-
[twoFactorState]="twoFactorState"
12+
[twoFactorState]="twoFactorEnabled"
1313
*ngIf="settingSecurityPasswordOpen"
1414
(loading)="settingSecurityPasswordLoading = $event"
1515
>
@@ -21,11 +21,11 @@ <h2 class="orc-font-body-large col" i18n="@@account.security">Security</h2>
2121
class="row"
2222
id="cy-2FA-panel"
2323
[title]="titleTwoFactor"
24-
[type]="{ value: 'two-factor', enabled: twoFactorState }"
24+
[type]="{ value: 'two-factor', enabled: twoFactorEnabled }"
2525
[loading]="settingSecurityTwoFactorLoading"
2626
>
2727
<app-settings-security-two-factor-auth
28-
[twoFactorState]="twoFactorState"
28+
[twoFactorInfo]="twoFactorInfo"
2929
(twoFactorStateOutput)="twoFactorStateChanges($event)"
3030
>
3131
</app-settings-security-two-factor-auth>
@@ -39,7 +39,7 @@ <h2 class="orc-font-body-large col" i18n="@@account.security">Security</h2>
3939
[loading]="settingSecurityAlternateAccountsLoading"
4040
>
4141
<app-settings-security-alternate-sign-in
42-
[twoFactorState]="twoFactorState"
42+
[twoFactorState]="twoFactorEnabled"
4343
(loading)="settingSecurityAlternateAccountsLoading = $event"
4444
*ngIf="settingSecurityAlternateAccounts"
4545
></app-settings-security-alternate-sign-in>

src/app/account-settings/components/settings-security/settings-security.component.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { Component, Inject, OnInit } from '@angular/core'
22
import { TwoFactorAuthenticationService } from '../../../core/two-factor-authentication/two-factor-authentication.service'
33
import { first } from 'rxjs/operators'
44
import { WINDOW } from 'src/app/cdk/window'
5+
import { Status } from '../../../types/two-factor.endpoint'
56

67
@Component({
78
selector: 'app-settings-security',
@@ -22,7 +23,8 @@ export class SettingsSecurityComponent implements OnInit {
2223
settingSecurityTwoFactorLoading = false
2324
settingSecurityAlternateAccountsLoading = false
2425

25-
twoFactorState = false
26+
twoFactorEnabled = false
27+
twoFactorInfo: Status | undefined
2628

2729
constructor(
2830
private twoFactorAuthenticationService: TwoFactorAuthenticationService,
@@ -34,7 +36,8 @@ export class SettingsSecurityComponent implements OnInit {
3436
.checkState()
3537
.pipe(first())
3638
.subscribe((result) => {
37-
this.twoFactorState = result.enabled
39+
this.twoFactorInfo = result
40+
this.twoFactorEnabled = result.enabled
3841
})
3942
const hash = this._window.location.hash.substr(1)
4043
switch (hash) {
@@ -51,6 +54,6 @@ export class SettingsSecurityComponent implements OnInit {
5154
}
5255

5356
twoFactorStateChanges($event) {
54-
this.twoFactorState = $event
57+
this.twoFactorEnabled = $event
5558
}
5659
}

src/app/types/two-factor.endpoint.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { AuthChallenge, ExtendedDate } from './common.endpoint'
2+
13
export interface TwoFactor {
24
orcid?: string
35
recoveryCode?: string
@@ -16,6 +18,8 @@ export interface QrCode {
1618
url: string
1719
}
1820

19-
export interface Status {
21+
export interface Status extends AuthChallenge {
2022
enabled: boolean
23+
twoFactorCreationDate: ExtendedDate
24+
recoveryCodeCreationDate: ExtendedDate
2125
}

0 commit comments

Comments
 (0)