aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/modal/confirm.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-10-07 11:06:28 +0200
committerChocobozzz <me@florianbigard.com>2022-10-07 11:06:28 +0200
commitd12b40fb96d56786a96c06a621f3d8e0a0d24f4a (patch)
tree7047fa5cd7e778eb377c897eccb539c52b2e59bc /client/src/app/modal/confirm.component.ts
parent56f47830758ff8e92abcfcc5f35d474ab12fe215 (diff)
downloadPeerTube-d12b40fb96d56786a96c06a621f3d8e0a0d24f4a.tar.gz
PeerTube-d12b40fb96d56786a96c06a621f3d8e0a0d24f4a.tar.zst
PeerTube-d12b40fb96d56786a96c06a621f3d8e0a0d24f4a.zip
Implement two factor in client
Diffstat (limited to 'client/src/app/modal/confirm.component.ts')
-rw-r--r--client/src/app/modal/confirm.component.ts30
1 files changed, 25 insertions, 5 deletions
diff --git a/client/src/app/modal/confirm.component.ts b/client/src/app/modal/confirm.component.ts
index ec4e1d60f..3bb8b9b21 100644
--- a/client/src/app/modal/confirm.component.ts
+++ b/client/src/app/modal/confirm.component.ts
@@ -21,6 +21,8 @@ export class ConfirmComponent implements OnInit {
21 inputValue = '' 21 inputValue = ''
22 confirmButtonText = '' 22 confirmButtonText = ''
23 23
24 isPasswordInput = false
25
24 private openedModal: NgbModalRef 26 private openedModal: NgbModalRef
25 27
26 constructor ( 28 constructor (
@@ -31,11 +33,27 @@ export class ConfirmComponent implements OnInit {
31 33
32 ngOnInit () { 34 ngOnInit () {
33 this.confirmService.showConfirm.subscribe( 35 this.confirmService.showConfirm.subscribe(
34 ({ title, message, expectedInputValue, inputLabel, confirmButtonText }) => { 36 payload => {
37 // Reinit fields
38 this.title = ''
39 this.message = ''
40 this.expectedInputValue = ''
41 this.inputLabel = ''
42 this.inputValue = ''
43 this.confirmButtonText = ''
44 this.isPasswordInput = false
45
46 const { type, title, message, confirmButtonText } = payload
47
35 this.title = title 48 this.title = title
36 49
37 this.inputLabel = inputLabel 50 if (type === 'confirm-expected-input') {
38 this.expectedInputValue = expectedInputValue 51 this.inputLabel = payload.inputLabel
52 this.expectedInputValue = payload.expectedInputValue
53 } else if (type === 'confirm-password') {
54 this.inputLabel = $localize`Confirm your password`
55 this.isPasswordInput = true
56 }
39 57
40 this.confirmButtonText = confirmButtonText || $localize`Confirm` 58 this.confirmButtonText = confirmButtonText || $localize`Confirm`
41 59
@@ -66,11 +84,13 @@ export class ConfirmComponent implements OnInit {
66 this.openedModal = this.modalService.open(this.confirmModal, { centered: true }) 84 this.openedModal = this.modalService.open(this.confirmModal, { centered: true })
67 85
68 this.openedModal.result 86 this.openedModal.result
69 .then(() => this.confirmService.confirmResponse.next(true)) 87 .then(() => {
88 this.confirmService.confirmResponse.next({ confirmed: true, value: this.inputValue })
89 })
70 .catch((reason: string) => { 90 .catch((reason: string) => {
71 // If the reason was that the user used the back button, we don't care about the confirm dialog result 91 // If the reason was that the user used the back button, we don't care about the confirm dialog result
72 if (!reason || reason !== POP_STATE_MODAL_DISMISS) { 92 if (!reason || reason !== POP_STATE_MODAL_DISMISS) {
73 this.confirmService.confirmResponse.next(false) 93 this.confirmService.confirmResponse.next({ confirmed: false, value: this.inputValue })
74 } 94 }
75 }) 95 })
76 } 96 }