Skip to content

Commit 64934d7

Browse files
authored
Merge branch 'main' into aromanovv/PD-4790-improve-auth-challenge
2 parents 66f6313 + d2f8e3d commit 64934d7

10 files changed

Lines changed: 1110 additions & 633 deletions

File tree

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,15 @@
1+
## v2.131.6 - 2026-03-12
2+
3+
[Full Changelog](https://github.com/ORCID/orcid-angular/compare/v2.131.5...v2.131.6)
4+
5+
- [#2767](https://github.com/ORCID/orcid-angular/pull/2767): PD-4792 add auth challenge to disable 2fa
6+
7+
## v2.131.5 - 2026-03-12
8+
9+
[Full Changelog](https://github.com/ORCID/orcid-angular/compare/v2.131.4...v2.131.5)
10+
11+
- [#2771](https://github.com/ORCID/orcid-angular/pull/2771): PD-5141
12+
113
## v2.131.4 - 2026-03-11
214

315
[Full Changelog](https://github.com/ORCID/orcid-angular/compare/v2.131.3...v2.131.4)

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,7 @@
1313
</div>
1414
</app-alert-message>
1515
}
16-
<p class="mb-4 mt-0" i18n>
17-
Change or update your account password.
18-
</p>
16+
<p class="mb-4 mt-0" i18n>Change or update your account password.</p>
1917
<div class="row mb-6 flex flex-wrap">
2018
<label
2119
class="row mat-caption"

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

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,17 @@
11
<app-settings-panels-data>
2+
@if (success) {
3+
<app-alert-message type="success" class="mb-4.5">
4+
<div content class="mt-0.5" i18n>
5+
Two-factor authentication has been disabled
6+
</div>
7+
</app-alert-message>
8+
} @if (cancel) {
9+
<app-alert-message type="warning" class="mb-4.5">
10+
<div content class="mt-0.5" i18n>
11+
Two-factor authentication was not disabled
12+
</div>
13+
</app-alert-message>
14+
}
215
<p>
316
<ng-container i18n="@@account.addExtraSecurity">
417
Add extra security to your ORCID account by enabling two-factor
Lines changed: 65 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,16 @@
11
import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core'
22
import { ApplicationRoutes } from '../../../constants'
33
import { Router } from '@angular/router'
4-
import { first } from 'rxjs/operators'
4+
import { first, takeUntil } from 'rxjs/operators'
55
import { TwoFactorAuthenticationService } from '../../../core/two-factor-authentication/two-factor-authentication.service'
6+
import { MatDialog } from '@angular/material/dialog'
7+
import { AuthChallengeComponent } from '@orcid/registry-ui'
8+
import { AuthChallengeFormData } from '../../../types/common.endpoint'
9+
import {
10+
UntypedFormBuilder,
11+
UntypedFormGroup,
12+
Validators,
13+
} from '@angular/forms'
614

715
@Component({
816
selector: 'app-settings-security-two-factor-auth',
@@ -16,35 +24,75 @@ import { TwoFactorAuthenticationService } from '../../../core/two-factor-authent
1624
export class SettingsSecurityTwoFactorAuthComponent implements OnInit {
1725
@Input() twoFactorState: boolean
1826
@Output() twoFactorStateOutput = new EventEmitter<any>()
19-
@Output() loading = new EventEmitter<boolean>()
27+
28+
form: UntypedFormGroup
29+
success = false
30+
cancel = false
31+
authChallengeLabel = $localize`:@@accountSettings.security.disable2FA:disable 2FA`
2032

2133
constructor(
2234
private _router: Router,
23-
private twoFactorAuthenticationService: TwoFactorAuthenticationService
35+
private twoFactorAuthenticationService: TwoFactorAuthenticationService,
36+
private _fb: UntypedFormBuilder,
37+
private _dialog: MatDialog
2438
) {}
2539

26-
ngOnInit(): void {}
27-
28-
disable() {
29-
this.twoFactorAuthenticationService
30-
.disable()
31-
.pipe(first())
32-
.subscribe((result) => {
33-
this.loading.next(false)
34-
if (!result.enabled) {
35-
this.twoFactorState = result.enabled
36-
this.twoFactorStateOutput.emit(false)
37-
}
40+
ngOnInit(): void {
41+
this.form = this._fb.group({
42+
password: [null, Validators.required],
43+
twoFactorCode: [null, [Validators.minLength(6), Validators.maxLength(6)]],
44+
twoFactorRecoveryCode: [
45+
null,
46+
[Validators.minLength(10), Validators.maxLength(10)],
47+
],
48+
})
49+
}
50+
51+
openAuthChallenge() {
52+
const dialogRef = this._dialog.open<AuthChallengeComponent>(
53+
AuthChallengeComponent,
54+
{
55+
data: {
56+
parentForm: this.form,
57+
actionDescription: this.authChallengeLabel,
58+
} as AuthChallengeFormData,
59+
}
60+
)
61+
62+
dialogRef.componentInstance.submitAttempt
63+
.pipe(takeUntil(dialogRef.afterClosed()))
64+
.subscribe(() => {
65+
this.twoFactorAuthenticationService
66+
.disable(this.form.value)
67+
.pipe(first())
68+
.subscribe({
69+
next: (response: any) => {
70+
if (response.success) {
71+
this.twoFactorState = response.enabled
72+
this.twoFactorStateOutput.emit(false)
73+
dialogRef.close(true)
74+
} else {
75+
dialogRef.componentInstance.loading = false
76+
dialogRef.componentInstance.processBackendResponse(response)
77+
}
78+
},
79+
})
3880
})
3981

82+
dialogRef.afterClosed().subscribe((success) => {
83+
if (success) {
84+
this.success = true
85+
} else {
86+
this.cancel = true
87+
}
88+
})
4089
}
4190

4291
twoFactor() {
4392
if (!this.twoFactorState) {
4493
this._router.navigate([ApplicationRoutes.twoFactorSetup])
4594
} else {
46-
this.loading.next(true)
47-
this.disable()
95+
this.openAuthChallenge()
4896
}
4997
}
5098
}

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ <h2 class="orc-font-body-large col" i18n="@@account.security">Security</h2>
2727
<app-settings-security-two-factor-auth
2828
[twoFactorState]="twoFactorState"
2929
(twoFactorStateOutput)="twoFactorStateChanges($event)"
30-
(loading)="settingSecurityTwoFactorLoading = $event"
3130
>
3231
</app-settings-security-two-factor-auth>
3332
</app-settings-panels>

src/app/core/two-factor-authentication/two-factor-authentication.service.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
import { catchError, retry } from 'rxjs/operators'
1212
import { ERROR_REPORT } from '../../errors'
1313
import { ErrorHandlerService } from '../error-handler/error-handler.service'
14+
import { AuthChallenge } from '../../types/common.endpoint'
1415

1516
@Injectable({
1617
providedIn: 'root',
@@ -31,10 +32,10 @@ export class TwoFactorAuthenticationService {
3132
)
3233
}
3334

34-
disable(): Observable<Status> {
35+
disable(data: AuthChallenge): Observable<Status> {
3536
return this._http.post<Status>(
3637
runtimeEnvironment.BASE_URL + '2FA/disable.json',
37-
{},
38+
data,
3839
{ headers: this.headers }
3940
)
4041
}

0 commit comments

Comments
 (0)