react-native-auth0 icon indicating copy to clipboard operation
react-native-auth0 copied to clipboard

requireLocalAuthentication does not work when used via useAuth hook

Open botre opened this issue 1 year ago • 3 comments

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 avatar Mar 19 '24 18:03 botre

We are planning to address this issue along with other improvements in the next major release coming up this quarter. I'll share exact timelines by the mid of June.

brth31 avatar May 28 '24 10:05 brth31

any update on this @brth31 ?

thyming avatar Jun 20 '24 20:06 thyming

Hi @botre , @thyming,

We've removed this API in v4 beta and made improvements around local authentication. Can you try it out once here and let us know how it goes ?

desusai7 avatar Sep 02 '24 07:09 desusai7

@botre @thyming Could we close this issue if it is resolved in v4 beta?

brth31 avatar Nov 15 '24 05:11 brth31

sounds good to me 👍🏻

On Fri, Nov 15, 2024 at 12:19 AM Bharath Natarajan @.***> wrote:

@botre https://github.com/botre @thyming https://github.com/thyming Could we close this issue if it is resolved in v4 beta?

— Reply to this email directly, view it on GitHub https://github.com/auth0/react-native-auth0/issues/880#issuecomment-2477981867, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQ5N2LKHTVTF36FB7DQYOL2AV76HAVCNFSM6AAAAABE6CVOJ2VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDINZXHE4DCOBWG4 . You are receiving this because you were mentioned.Message ID: @.***>

thyming avatar Nov 18 '24 15:11 thyming

Closing this issue as it appears to be addressed in v4.0.0. Please update to the latest version and retest. Reopen this issue if you continue to experience the problem.

arpit-jn avatar Jan 08 '25 15:01 arpit-jn