fix passphrase scanning (#1553)
This commit is contained in:
parent
a67ef43f6e
commit
0891e51c9e
@ -1126,7 +1126,7 @@ function QrPassword ({ value }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
function PasswordScanner ({ onScan }) {
|
function PasswordScanner ({ onScan, text }) {
|
||||||
const showModal = useShowModal()
|
const showModal = useShowModal()
|
||||||
const toaster = useToast()
|
const toaster = useToast()
|
||||||
|
|
||||||
@ -1136,26 +1136,29 @@ function PasswordScanner ({ onScan }) {
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
showModal(onClose => {
|
showModal(onClose => {
|
||||||
return (
|
return (
|
||||||
<Scanner
|
<div>
|
||||||
formats={['qr_code']}
|
{text && <h5 className='line-height-md mb-4 text-center'>{text}</h5>}
|
||||||
onScan={([{ rawValue: result }]) => {
|
<Scanner
|
||||||
onScan(result)
|
formats={['qr_code']}
|
||||||
onClose()
|
onScan={([{ rawValue: result }]) => {
|
||||||
}}
|
onScan(result)
|
||||||
styles={{
|
onClose()
|
||||||
video: {
|
}}
|
||||||
aspectRatio: '1 / 1'
|
styles={{
|
||||||
}
|
video: {
|
||||||
}}
|
aspectRatio: '1 / 1'
|
||||||
onError={(error) => {
|
}
|
||||||
if (error instanceof DOMException) {
|
}}
|
||||||
console.log(error)
|
onError={(error) => {
|
||||||
} else {
|
if (error instanceof DOMException) {
|
||||||
toaster.danger('qr scan: ' + error?.message || error?.toString?.())
|
console.log(error)
|
||||||
}
|
} else {
|
||||||
onClose()
|
toaster.danger('qr scan: ' + error?.message || error?.toString?.())
|
||||||
}}
|
}
|
||||||
/>
|
onClose()
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
}}
|
}}
|
||||||
@ -1167,9 +1170,10 @@ function PasswordScanner ({ onScan }) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
export function PasswordInput ({ newPass, qr, copy, readOnly, append, value, ...props }) {
|
export function PasswordInput ({ newPass, qr, copy, readOnly, append, value: initialValue, ...props }) {
|
||||||
const [showPass, setShowPass] = useState(false)
|
const [showPass, setShowPass] = useState(false)
|
||||||
const [field, helpers] = props.noForm ? [{ value }, {}, {}] : useField(props)
|
const [value, setValue] = useState(initialValue)
|
||||||
|
const [field,, helpers] = props.noForm ? [{ value }, {}, { setValue }] : useField(props)
|
||||||
|
|
||||||
const Append = useMemo(() => {
|
const Append = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
@ -1181,12 +1185,13 @@ export function PasswordInput ({ newPass, qr, copy, readOnly, append, value, ...
|
|||||||
{qr && (readOnly
|
{qr && (readOnly
|
||||||
? <QrPassword value={field?.value} />
|
? <QrPassword value={field?.value} />
|
||||||
: <PasswordScanner
|
: <PasswordScanner
|
||||||
|
text="Where'd you learn to square dance?"
|
||||||
onScan={v => helpers.setValue(v)}
|
onScan={v => helpers.setValue(v)}
|
||||||
/>)}
|
/>)}
|
||||||
{append}
|
{append}
|
||||||
</>
|
</>
|
||||||
)
|
)
|
||||||
}, [showPass, copy, field?.value, qr, readOnly, append])
|
}, [showPass, copy, field?.value, helpers.setValue, qr, readOnly, append])
|
||||||
|
|
||||||
const style = props.style ? { ...props.style } : {}
|
const style = props.style ? { ...props.style } : {}
|
||||||
if (props.as === 'textarea') {
|
if (props.as === 'textarea') {
|
||||||
|
@ -522,7 +522,7 @@ export const deviceSyncSchema = object().shape({
|
|||||||
try {
|
try {
|
||||||
await string().oneOf(bip39Words).validate(w)
|
await string().oneOf(bip39Words).validate(w)
|
||||||
} catch {
|
} catch {
|
||||||
return context.createError({ message: `'${w}' is not a valid pairing phrase word` })
|
return context.createError({ message: `'${w.slice(0, 10)}${w.length > 10 ? '...' : ''}' is not a valid pairing phrase word` })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user