You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using loginwithpopup (Auth0's sdk link) to open the Auth0's universal login MFA enrollment prompt in a popup window. The issue we are encountering is we cannot find a way to handle if the user closes/cancels the popup page. The expected behavior is that when the user closes the popup, it should return us an error to indicate it so we could catch it and display an error on our app to instruct the user to click the button to open the popup again. We've tried the solutions from auth0/auth0-spa-js#599 but it doesn't work because we don't receive any error response. The happy path works fine
This is the code we use
JeremyLiang0105
changed the title
loginWithPopup closedoesn't return any error response
loginWithPopup close doesn't return any error response
Jan 13, 2025
Hey @JeremyLiang0105
The paradigm with auth0-react is different than the one in auth0-spa-js. useAuth0().loginWithPopup won't throw an error if it fails. Instead, it will update the error state (obtained from useAuth0().error), so that your components can react to it.
A crude example:
constmyComponent=()=>{const{ error, isLoading, isAuthenticated }=useAuth0();if(error){return<div>There was an error while authenticating: {error}</div>;}// ...}
Checklist
Description
We are using loginwithpopup (Auth0's sdk link) to open the Auth0's universal login MFA enrollment prompt in a popup window. The issue we are encountering is we cannot find a way to handle if the user closes/cancels the popup page. The expected behavior is that when the user closes the popup, it should return us an error to indicate it so we could catch it and display an error on our app to instruct the user to click the button to open the popup again. We've tried the solutions from auth0/auth0-spa-js#599 but it doesn't work because we don't receive any error response. The happy path works fine
This is the code we use
No error is being thrown when the user closes the popup without completing the steps.
The version of auth0-react we are using is "@auth0/auth0-react": "1.12.1"
Reproduction
Code snippet copied above.
Additional context
No response
auth0-react version
1.12.1
React version
18
Which browsers have you tested in?
Chrome
The text was updated successfully, but these errors were encountered: