From 94033770335102d704594d79928d0e11985957fa Mon Sep 17 00:00:00 2001 From: ng <�> Date: Sun, 23 Oct 2022 02:52:08 +0200 Subject: feat: 🔒️ Add password check field MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/bank/src/pages/home/index.tsx | 41 ++++++++++++++++++++++++++++++++-- packages/bank/src/scss/bank.scss | 2 +- 2 files changed, 40 insertions(+), 3 deletions(-) (limited to 'packages') diff --git a/packages/bank/src/pages/home/index.tsx b/packages/bank/src/pages/home/index.tsx index b9d3633..df07f90 100644 --- a/packages/bank/src/pages/home/index.tsx +++ b/packages/bank/src/pages/home/index.tsx @@ -77,6 +77,7 @@ interface TransactionRequestType { interface CredentialsRequestType { username: string; password: string; + passwordrepeat?: string; } /** @@ -1540,6 +1541,21 @@ const RegistrationForm = (Props: any): VNode => { password: e.currentTarget.value, })) }} /> +

+ { + submitDataSetter((submitData: any) => ({ + ...submitData, + passwordrepeat: e.currentTarget.value, + })) + }} + />
{/* @@ -1577,8 +1593,22 @@ const RegistrationForm = (Props: any): VNode => { console.log('username or password are the empty string'); return; } + if (submitData.passwordrepeat?.length === 0) { + console.log('passrepeat empty'); + return; + } + if (submitData.passwordrepeat !== submitData.password) { + pageStateSetter((prevState: any) => ({ + ...prevState, + hasError: true, + error: `Passwords did not match!` + })) + console.log('password does not match repeat'); + return; + } console.log('submitting the registration..'); document.body.classList.add('transition-login') + delete submitData.passwordrepeat; registrationCall( { ...submitData }, Props.backendStateSetter, // will store BE URL, if OK. @@ -1593,7 +1623,7 @@ const RegistrationForm = (Props: any): VNode => { * strings due to a non lively update of the fields * after setting to undefined. */ - submitDataSetter({ username: '', password: '' }) + submitDataSetter({ username: '', password: '', passwordrepeat: '' }) }}> {i18n`Register`} @@ -1753,7 +1783,14 @@ function Account(Props: any): VNode { } } } - if (!data) return

Retrieving the profile page...

; + if (!data) return

Retrieving the profile page...

; /** * This block shows the withdrawal QR code. diff --git a/packages/bank/src/scss/bank.scss b/packages/bank/src/scss/bank.scss index 5b8b156..85d9856 100644 --- a/packages/bank/src/scss/bank.scss +++ b/packages/bank/src/scss/bank.scss @@ -252,7 +252,7 @@ input { box-shadow: none; } - input[placeholder="Password"][type="password"] { + input#register-pw-check[placeholder="Password"][type="password"] { margin-bottom: 8px; } -- cgit v1.2.3