Okta throwing "Cannot read property 'token' of undefined" error after providing email id in forgot password form

Hi there!

I’m using okta sign in widget code in my react app.
Login part is quite okay its working as expected,
but there is an issue with forgot password on okta sign in widget.
After providing email id in the forgot password form, its throwing below error, but anyways its sending email.
Can someone help me to resolve this issue.

TypeError: Cannot read property ‘token’ of undefined

Login._this.onSuccess

src/components/auth/Login.js:30

  27 |   28 | onSuccess = (res) => {  29 |   return this.props.auth.redirect({> 30 |     sessionToken: res.session.token,  31 |   });  32 | };  33 | 

View compiled

▼ 3 stack frames were expanded.

executeBound

node_modules/underscore/underscore.js:701

bound

node_modules/underscore/underscore.js:733

(anonymous function)

node_modules/underscore/underscore.js:768

▲ 3 stack frames were expanded.

Thanks in advance.

Here is my code snippet:

import React, { Component } from “react”;
import { Redirect } from “react-router-dom”;
import SignInWidget from “./SignInWidget”;
import { withAuth } from “@okta/okta-react”;

export default withAuth(
class Login extends Component {
constructor(props) {
super(props);
this.state = {
authenticated: null,
};
this.checkAuthentication();
}

async checkAuthentication() {
  const authenticated = await this.props.auth.isAuthenticated();
  if (authenticated !== this.state.authenticated) {
    this.setState({ authenticated });
    localStorage.setItem("isAuthenticated", authenticated);
  }
}

componentDidUpdate() {
  this.checkAuthentication();
}

onSuccess = (res) => {
  return this.props.auth.redirect({
    sessionToken: res.session.token,
  });
};

onError = (err) => {
  localStorage.setItem("isAuthenticated", false);
  console.log("error logging in", err);
};

render() {
  if (this.state.authenticated === null) return null;
  return this.state.authenticated ? (
    <Redirect to={{ pathname: "/" }} />
  ) : (
    <SignInWidget
      baseUrl={this.props.baseUrl}
      onSuccess={this.onSuccess}
      onError={this.onError}
    />
  );
}

}
);