Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

requireLocalAuthentication does not work when used via useAuth hook #880

Open
6 tasks done
botre opened this issue Mar 19, 2024 · 0 comments
Open
6 tasks done

requireLocalAuthentication does not work when used via useAuth hook #880

botre opened this issue Mar 19, 2024 · 0 comments
Labels
bug This points to a verified bug in the code

Comments

@botre
Copy link

botre commented Mar 19, 2024

Checklist

Description

The requireLocalAuthentication method exposed by the useAuth hook does not seem to work.

I have a hunch that it is because requireLocalAuthentication cannot be called after getCredentials, however a useEffect in Auth0Provider.tsx (line 79) calls getCredentials on mount. So this condition cannot be satisfied.

I can call the requireLocalAuthentication method exposed by the Auth0 directly as a workaround:

const configureLocalAuthentication = async () => {
  const auth0 = new Auth0({
    clientId,
    domain,
  })
  try {
    await auth0.credentialsManager.requireLocalAuthentication()
  } catch (error) {
    console.error(error)
  }
}

export const AuthManager = ({ children }: PropsWithChildren) => {
  useEffect(() => {
    configureLocalAuthentication()
  }, [])
  return (
    <Auth0Provider domain={domain} clientId={clientId} >
      {children}
    </Auth0Provider>
  )
}

I have tested this on a real device.

Reproduction

  1. Setup the provider
  2. Down the tree, call the requireLocalAuthentication exposed by the useAuth hook
useEffect(() => {
    requireLocalAuthentication()
  }, [requireLocalAuthentication])
  1. Nothing happens.

Additional context

No response

react-native-auth0 version

3.1.0

React Native version

0.72.10

Expo version

49.0.23

Platform

iOS

Platform version(s)

17.4

@botre botre added the bug This points to a verified bug in the code label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This points to a verified bug in the code
Projects
None yet
Development

No branches or pull requests

1 participant