diff options
author | Sebastian <sebasjm@gmail.com> | 2023-03-13 00:24:28 -0300 |
---|---|---|
committer | Sebastian <sebasjm@gmail.com> | 2023-03-13 00:24:28 -0300 |
commit | 3267f56dc3de054a7dbdd6cd83305b92cf16bd61 (patch) | |
tree | 5f3b77915e5bc9af05bfeed30436e70b372e3d21 /packages/merchant-backoffice-ui/src/paths | |
parent | a1af7945d17d40b33aeaf3894ed348b083f98f9a (diff) | |
download | wallet-core-3267f56dc3de054a7dbdd6cd83305b92cf16bd61.tar.xz |
show/hide key
Diffstat (limited to 'packages/merchant-backoffice-ui/src/paths')
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx | 14 | ||||
-rw-r--r-- | packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx | 34 |
2 files changed, 44 insertions, 4 deletions
diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx index 66ac72ff5..a6b616907 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/qr/QrPage.tsx @@ -96,20 +96,30 @@ export function QrPage({ template, id: templateId, onBack }: Props): VNode { : template.pos_algorithm === 2 ? `otpauth://totp/${issuer}:${templateId}?secret=${template.pos_key}&issuer=${issuer}&algorithm=SHA1&digits=8&period=30` : undefined; + + const keySlice = template.pos_key?.substring(0, 4); + + const oauthUriWithoutSecret = !template.pos_algorithm + ? undefined + : template.pos_algorithm === 1 + ? `otpauth://totp/${issuer}:${templateId}?secret=${keySlice}...&issuer=${issuer}&algorithm=SHA1&digits=8&period=30` + : template.pos_algorithm === 2 + ? `otpauth://totp/${issuer}:${templateId}?secret=${keySlice}...&issuer=${issuer}&algorithm=SHA1&digits=8&period=30` + : undefined; return ( <div> {oauthUri && ( <ConfirmModal description="Setup TOTP" active={setupTOTP} - onConfirm={() => { + onCancel={() => { setSetupTOTP(false); }} > <p>Scan this qr code with your TOTP device</p> <QR text={oauthUri} /> <pre style={{ textAlign: "center" }}> - <a href={oauthUri}>{oauthUri}</a> + <a href={oauthUri}>{oauthUriWithoutSecret}</a> </pre> </ConfirmModal> )} diff --git a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx index e34e2c746..9fcfcc4bf 100644 --- a/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx +++ b/packages/merchant-backoffice-ui/src/paths/instance/templates/update/UpdatePage.tsx @@ -57,6 +57,7 @@ export function UpdatePage({ template, onUpdate, onBack }: Props): VNode { const { i18n } = useTranslationContext(); const backend = useBackendContext(); + const [showKey, setShowKey] = useState(false); const [state, setState] = useState<Partial<Entity>>(template); const errors: FormErrors<Entity> = { @@ -161,14 +162,26 @@ export function UpdatePage({ template, onUpdate, onBack }: Props): VNode { convert={(v) => Number(v)} /> {state.pos_algorithm && state.pos_algorithm > 0 ? ( - <Input<Entity> + <InputWithAddon<Entity> name="pos_key" label={i18n.str`Point-of-sale key`} + inputType={showKey ? "text" : "password"} help="" + expand tooltip={i18n.str`Useful to validate the purchase`} + addonAfter={ + <span class="icon"> + {showKey ? ( + <i class="mdi mdi-eye" /> + ) : ( + <i class="mdi mdi-eye-off" /> + )} + </span> + } side={ - <span data-tooltip={i18n.str`generate random secret key`}> + <span> <button + data-tooltip={i18n.str`generate random secret key`} class="button is-info mr-3" onClick={(e) => { const pos_key = randomBase32Key(); @@ -177,6 +190,23 @@ export function UpdatePage({ template, onUpdate, onBack }: Props): VNode { > <i18n.Translate>random</i18n.Translate> </button> + <button + data-tooltip={ + showKey + ? i18n.str`show secret key` + : i18n.str`hide secret key` + } + class="button is-info mr-3" + onClick={(e) => { + setShowKey(!showKey); + }} + > + {showKey ? ( + <i18n.Translate>hide</i18n.Translate> + ) : ( + <i18n.Translate>show</i18n.Translate> + )} + </button> </span> } /> |