Alright? Next I'm dealing with this error when logging in using Auth0 with React JS:
I'veresearchedseveralsites,reorganizedmycodecountlesstimes,debuggingfor3daysandnothing.IamperformingaloginwithAuth0.Checkoutmycomponentsandmethodsbelow:
Index.js:
ReactDOM.render(<Providerstore={store}><Routerhistory={history}><App/></Router></Provider>,document.getElementById(root)
Routes.js
constauth=newAuth();consthandleAuthentication=({location})=>{if(/access_token|id_token|error/.test(location.hash)){auth.handleAuthentication();}};classRoutesextendsComponent{render(){return(<Switch><Routeexactpath="/" component={Index}/>
<Route path="/services/:id" component=
{ServiceDescriptionPanel}/>
<Route path="/post" component={BlogPage}/>
<Route path="/contact" component={Contact}/>
<Route path="/login" render={props => <Login auth={auth}
{...props} /> }/>
<Route path="/admin" render={(props) => {
handleAuthentication(props);
return <Admin auth={this.props.auth} {...props} />
}}/>
<Route path="/admin_post" component={AdminPost}/>
</Switch>
)
}
}
export default Routes
App.js
render() {
// ContainerQuery é o componente que tratará as classe CSS escolhida
para cada resolução
// 'params' vai ser a classe CSS escolhida com base na resolução do
dispositivo
// 'classNames(params)' é um modulo NPM que trata várias classNames sem
que o Dev precise digitar tudo
// .. ela apenas retorna toda uma 'string' de className
return (
<ContainerQuery query={query}>
{params => (
<div className={classNames(params)} style={{backgroundColor:
"#f0f2f5"}}>
<div className="container">
<Banner/>
<Nav isMobile={isMobile}/>
<BackTop style={{right: 30}}/>
<Routes />
<Footer/>
</div>
</div>
)}
</ContainerQuery>
);
}
Login.js (component that I call when I want to log in and from here the user is redirected to the Auth0 site to login)
class Login extends Component {
componentDidMount(){
this.props.auth.login()
}
render() {
return (
<div className="stylePageDefault">
<h3>Redirecionando...</h3>
</div>
)
}
}
export default Login
Thank you for your attention.
Note: In the Auth0 DashBoard, the login is successful, that is, it is logging in, the problem is when the token returns ...