-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathsettings-security.component.ts
More file actions
59 lines (52 loc) · 1.88 KB
/
Copy pathsettings-security.component.ts
File metadata and controls
59 lines (52 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import { Component, Inject, OnInit } from '@angular/core'
import { TwoFactorAuthenticationService } from '../../../core/two-factor-authentication/two-factor-authentication.service'
import { first } from 'rxjs/operators'
import { WINDOW } from 'src/app/cdk/window'
import { Status } from '../../../types/two-factor.endpoint'
@Component({
selector: 'app-settings-security',
templateUrl: './settings-security.component.html',
styleUrls: ['./settings-security.component.scss'],
standalone: false,
})
export class SettingsSecurityComponent implements OnInit {
titleAccountPassword = $localize`:@@account.accountPassword:Account password`
titleTwoFactor = $localize`:@@account.twoPassword:Two-factor authentication`
titleAlternativeSignin = $localize`:@@account.alternativeSignin:Alternate sign in accounts`
settingSecurityPasswordOpen = false
settingSecurityTwoFactor = false
settingSecurityAlternateAccounts = false
settingSecurityPasswordLoading = false
settingSecurityTwoFactorLoading = false
settingSecurityAlternateAccountsLoading = false
twoFactorEnabled = false
twoFactorInfo: Status | undefined
constructor(
private twoFactorAuthenticationService: TwoFactorAuthenticationService,
@Inject(WINDOW) private _window: Window
) {}
ngOnInit(): void {
this.twoFactorAuthenticationService
.checkState()
.pipe(first())
.subscribe((result) => {
this.twoFactorInfo = result
this.twoFactorEnabled = result.enabled
})
const hash = this._window.location.hash.substr(1)
switch (hash) {
case 'password':
this.settingSecurityPasswordOpen = true
break
case '2FA':
this.settingSecurityTwoFactor = true
break
case 'alternate-signin':
this.settingSecurityAlternateAccounts = true
break
}
}
twoFactorStateChanges($event) {
this.twoFactorEnabled = $event
}
}