-
Notifications
You must be signed in to change notification settings - Fork 290
Description
Please do not report security vulnerabilities here. The Responsible Disclosure Program details the procedure for disclosing security issues.
Thank you in advance for helping us to improve this library! Please read through the template below and answer all relevant questions. Your additional work here is greatly appreciated and will help us respond as quickly as possible. For general support or usage questions, use the Auth0 Community or Auth0 Support. Finally, to avoid duplicates, please search existing Issues before submitting one here.
By submitting an Issue to this repository, you agree to the terms within the Auth0 Code of Conduct.
Description
When using Aut0/auth0-react and the useAuth0 hook:
const { isAuthenticated, user, loginWithRedirect, logout } = useAuth0();
After logging in the application isAuthenticated is still false and user is undefined.
Reproduction
Add the package and follow direction on the Auth0 quick start page https://auth0.com/docs/quickstart/spa/react/01-login
login the application and get automatically redirected to the home page.
Where applicable, please include:
import {useAuth0} from "@auth0/auth0-react";
const NavBar = () => {
const classes = useStyles();
const { isAuthenticated, loginWithRedirect, logout } = useAuth0();
console.log(isAuthenticated);
return (
<div className={classes.root}>
<AppBar position="static" className={classes.navBar}>
<Toolbar>
<IconButton edge="start" className={classes.menuButton} color="inherit" aria-label="menu">
<MenuIcon />
</IconButton>
<Typography variant="h6" className={classes.title}>
Child Life Disaster Relief
</Typography>
<Button color="inherit" className={classes.button} onClick={logout}>Logout</Button>
{!isAuthenticated &&
<Button color="inherit" className={classes.button} onClick={loginWithRedirect}>Login</Button>
}
</Toolbar>
</AppBar>
</div>
);
};
export default NavBar;
Index.js
import React from 'react';
import ReactDOM from 'react-dom';
import './index.css';
import App from './App';
import * as serviceWorker from './serviceWorker';
import { Auth0Provider } from "@auth0/auth0-react";
ReactDOM.render(
<React.StrictMode>
<Auth0Provider
domain={process.env.REACT_APP_DOMAIN}
clientId={process.env.REACT_APP_CLIENT_ID}
redirectUri={window.location.origin}
>
<App />
</Auth0Provider>
</React.StrictMode>,
document.getElementById('root')
);
// If you want your app to work offline and load faster, you can change
// unregister() to register() below. Note this comes with some pitfalls.
// Learn more about service workers: https://bit.ly/CRA-PWA
serviceWorker.unregister();
- Log files (redact/remove sensitive information)
- Application settings (redact/remove sensitive information)
- Screenshots
Environment
Versions:
"dependencies": {
"@auth0/auth0-react": "^1.0.0",
"@date-io/date-fns": "1.x",
"@material-ui/core": "^4.11.0",
"@material-ui/icons": "^4.9.1",
"@material-ui/styles": "^4.10.0",
"@testing-library/jest-dom": "^4.2.4",
"@testing-library/react": "^9.3.2",
"@testing-library/user-event": "^7.1.2",
"date-fns": "^2.15.0",
"formik": "^2.1.5",
"formik-material-ui": "^3.0.0-alpha.0",
"formik-material-ui-pickers": "^0.0.11",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-scripts": "3.4.1"
},