fix: ask for pin on startup

This commit is contained in:
Filipe Medeiros 2021-12-03 18:19:05 +00:00
parent 5ef7b0137c
commit 10cb2d743f
2 changed files with 15 additions and 11 deletions

View file

@ -145,7 +145,7 @@ const TopMenu: FC<Props> = () => {
boxShadow: `${colors.coolGray[900]} 0px 2px 15px`, boxShadow: `${colors.coolGray[900]} 0px 2px 15px`,
}} }}
> >
{!isiOS && ( {/* {!isiOS && (
<li role="menuitem"> <li role="menuitem">
<button <button
disabled={!showPreferences} disabled={!showPreferences}
@ -164,7 +164,7 @@ const TopMenu: FC<Props> = () => {
<FingerPrintIcon className="h-full" /> <FingerPrintIcon className="h-full" />
</button> </button>
</li> </li>
)} )} */}
<li role="menuitem"> <li role="menuitem">
<button <button
disabled={!showPreferences} disabled={!showPreferences}

View file

@ -1,16 +1,19 @@
import { FingerPrintIcon } from '@heroicons/react/outline'
import { useRouter } from 'next/dist/client/router' import { useRouter } from 'next/dist/client/router'
import { useEffect } from 'react' import { useEffect } from 'react'
import PinPad from '../components/PinPad'
import { checkBiometrics } from '../lib/biometrics' import { checkBiometrics } from '../lib/biometrics'
import { getPreference } from '../lib/db/preferences' import { usePreferences } from '../lib/context/preferencesContext'
const Landing = () => { const Landing = () => {
const { push } = useRouter() const { push } = useRouter()
const {
preferences: { biometricsAuth },
} = usePreferences()
useEffect(() => { useEffect(() => {
const auth = async () => { const auth = async () => {
if (await getPreference('biometricsAuth')) { if (biometricsAuth) {
try { try {
await checkBiometrics() await checkBiometrics()
push('/dashboard') push('/dashboard')
@ -18,14 +21,15 @@ const Landing = () => {
} }
} }
auth() auth()
}, [push]) }, [push, biometricsAuth])
return ( return (
<main className="flex flex-col items-center w-full h-full justify-evenly"> <main className="flex flex-col items-center w-full h-full">
<header className="flex flex-col justify-center h-24"> <h1 className="text-4xl font-medium mb-16">welcome</h1>
<h1 className="text-4xl">welcome</h1> <button className="p-3 dark:bg-gray-800 bg-purple-50 mb-3 rounded shadow hover:cursor-pointer">
</header> <FingerPrintIcon className="h-16 text-gray-900 dark:text-purple-50" />
<PinPad /> </button>
<h2>please sign in with your biometrics</h2>
</main> </main>
) )
} }