I have made a login component which accepts an email and password to authenticate users and am using OktaAuth and its SignIn flow to authenticate and get the session token. However, redirecting to a secure route redirects to the Okta sign in widget and authState.isAuthenticated is also false. Here is the code snippet:
this.oktaAuth.signIn({
username: this.state.email,
password: this.state.password
})
.then(res => {
this.setState({
session_token: res.sessionToken,
authenticated: true
})
and in my render method:
if (this.state.authenticated) {
// this.oktaAuth.session.setCookieAndRedirect(this.state.session_token, "/");
this.props.authService.redirect("/home" + this.state.email, {sessionToken: this.state.session_token, email: this.state.email});
return null;
}
/home/email is a protected route. I want to know how I can redirect to it after pressing the login button which triggers the first snippet of code.