Skip to content

Commit fc330e9

Browse files
feat: add passphrase confirmation (#138)
1 parent 0f86dab commit fc330e9

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

gen-web/res/index.html

+6
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,12 @@ <h1 class="step-title">
154154
<input id="seed-passphrase" class="input" name="seed-passphrase" type="text"/>
155155
</div>
156156
<span id="seed-passphrase-error-message" class="error-red"></span>
157+
158+
<div id="confirm-passphrase-form-item" class="input-container confirm-passphrase">
159+
<label id="confirm-passphrase-label" class="input-label" for="confirm-passphrase">Confirm Passphrase</label>
160+
<input id="confirm-passphrase" class="input" name="confirm-passphrase" type="text"/>
161+
</div>
162+
<span id="confirm-passphrase-error-message" class="error-red"></span>
157163
</div>
158164

159165

gen-web/res/style.css

+4-2
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,9 @@ form > .input-container:not(:first-child) {
235235
margin-bottom: 10px;
236236
}
237237

238-
238+
.confirm-passphrase {
239+
margin-top: 30px;
240+
}
239241

240242
/* Image & Icon Elements */
241243
.holo-banner {
@@ -651,7 +653,7 @@ button {
651653
background-color: #ffffff;
652654
width: 151px;
653655
height: 42px;
654-
box-sizing: border-box;
656+
box-sizing: border-box;
655657
}
656658

657659
.action-button,

gen-web/src/index.js

+16-4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
const inputs = {
5151
registrationCode: document.querySelector('#registration-code'),
5252
seedPassphrase: document.querySelector('#seed-passphrase'),
53+
confirmPassphrase: document.querySelector('#confirm-passphrase'),
5354
email: document.querySelector('#email'),
5455
password: document.querySelector('#password'),
5556
passwordCheck: document.querySelector('#password-check'),
@@ -61,6 +62,7 @@
6162
emailInputArea: document.querySelector('#email-form-item'),
6263
registrationCodeInputArea: document.querySelector('#registration-code-form-item'),
6364
seedPassphraseInputArea: document.querySelector('#seed-passphrase-form-item'),
65+
confirmPassphraseInputArea: document.querySelector('#confirm-passphrase-form-item'),
6466
emailReadOnly: document.querySelector('#email-read-only'),
6567
passwordInputArea: document.querySelector('#password-form-item'),
6668
passwordCheckInputArea: document.querySelector('#password-check-form-item'),
@@ -73,6 +75,7 @@
7375
const errorMessages = {
7476
missingFields: 'Please complete missing fields.',
7577
seedPassphrase: 'Your passphrase needs to be at least 20 characters in length',
78+
confirmPassphrase: 'Passphrases do not match',
7679
registrationCode: 'Invalid code',
7780
email: 'Invalid email format',
7881
password: 'Your password needs to be at least 8 characters in length',
@@ -88,6 +91,7 @@
8891

8992
// global variable used to pass seed passphrase between steps 2 and 3
9093
let seedPassphrase
94+
let confirmPassphrase
9195

9296
/** Actions executed at button click
9397
* ======================================
@@ -124,6 +128,7 @@
124128
return
125129
}
126130
seedPassphrase = inputs.seedPassphrase.value
131+
confirmPassphrase = inputs.confirmPassphrase.value
127132

128133
updateUiStep(3)
129134
updateProgressBar(2)
@@ -247,7 +252,7 @@
247252
buttons.genSeed.disabled = true
248253
buttons.genSeed.innerHTML = 'Saved Seed & Key Files'
249254
verifySeedDownloadComplete(downloadSeedTracker)
250-
}, 2000)
255+
}, 2000)
251256
},
252257
download: async () => {
253258
/* Communicate visually that something is happening in the background */
@@ -414,12 +419,14 @@
414419
/* Bind input actions to inputArea actions */
415420
inlineVariables.registrationCodeInputArea.onclick = e => { inputs.registrationCode.focus(); return click.activateInput(e) }
416421
inlineVariables.seedPassphraseInputArea.onclick = e => { inputs.seedPassphrase.focus(); return click.activateInput(e) }
422+
inlineVariables.confirmPassphraseInputArea.onclick = e => { inputs.confirmPassphrase.focus(); return click.activateInput(e) }
417423
inlineVariables.emailInputArea.onclick = e => { inputs.email.focus(); return click.activateInput(e) }
418424
inlineVariables.passwordInputArea.onclick = e => { inputs.password.focus(); return click.activateInput(e) }
419425
inlineVariables.passwordCheckInputArea.onclick = e => { inputs.passwordCheck.focus(); return click.activateInput(e) }
420426
/* Bind actions to inputs */
421427
inputs.registrationCode.onfocus = click.activateInput
422428
inputs.seedPassphrase.onfocus = click.activateInput
429+
inputs.confirmPassphrase.onfocus = click.activateInput
423430
inputs.email.onfocus = click.activateInput
424431
inputs.password.onfocus = click.activateInput
425432
inputs.passwordCheck.onfocus = click.activateInput
@@ -528,7 +535,6 @@
528535
// with an invalid registration code. The purpose is simply to prevent users from wasting time setting up a
529536
// HoloPort with the wrong code.
530537
const verifyRegistrationCode = async ({ registration_code, email }) => {
531-
532538
const response = await fetch(`${MEMBRANE_PROOF_SERVICE_URL}/registration/api/v1/verify-registration-code`,
533539
{
534540
method: 'POST',
@@ -683,6 +689,7 @@
683689
*/
684690
const resetFields = (inputElements) => {
685691
inlineVariables.formErrorMessage.innerHTML = ''
692+
686693
for (let inputElement of inputElements) {
687694
inputElement.classList.remove('error-red')
688695
document.querySelector(`#${inputElement.id}-error-message`).innerHTML = ''
@@ -766,14 +773,19 @@
766773
return valid
767774
}
768775
const confirmValidPassPhrase = () => {
769-
const inputElements = Object.values({ seedPassphrase: inputs.seedPassphrase })
776+
const inputElements = Object.values({ seedPassphrase: inputs.seedPassphrase, confirmPassphrase: inputs.confirmPassphrase })
770777
resetFields(inputElements)
778+
771779
if (!inputs.seedPassphrase.value) {
772780
const missingFields = inputElements.filter(inputs => !inputs.value)
773781
renderInputError(errorMessages.missingFields, missingFields)
774782
} else if (!validatePassphrae(inputs.seedPassphrase.value)) {
775783
renderInputError(errorMessages.seedPassphrase, [inputs.seedPassphrase])
776-
} else return true
784+
} else if (inputs.seedPassphrase.value !== inputs.confirmPassphrase.value) {
785+
renderInputError(errorMessages.confirmPassphrase, [inputs.confirmPassphrase])
786+
} else {
787+
return true
788+
}
777789
}
778790

779791
})()

0 commit comments

Comments
 (0)