React-OpenIdConnect icon indicating copy to clipboard operation
React-OpenIdConnect copied to clipboard

userLoaded not called

Open bbehling-trimble opened this issue 6 years ago • 3 comments

I'm using an identity OAUTH server that returns an access_token. is this why userLoaded is not getting called? If not, any ideas why this isn't called?

bbehling-trimble avatar Apr 10 '19 20:04 bbehling-trimble

We are running into the same problem, did you figure out what was wrong? access_token and id_token are specified in the url as expected, but still, only NotAuthenticated gets called.

LasseMoench avatar Oct 18 '19 10:10 LasseMoench

@LasseMoench The code specifically looks for "#id_token" in the URL. If you have access_token, it might be first, so the code won't work.

swbradsh avatar Oct 28 '19 21:10 swbradsh

This PR should help to fix this issue.

So you can create a function to overwrite the way that you check for the token or even implement anything else to do it.

...
class YourComponent extends Component { 
  ...
  checkAuthentication() {
    return window.location.href.includes("my_token_hash"); 
  }

  render() {
      return (
        <Authenticate         
          OidcSettings={OidcSettings} 
          checkAuthentication={checkAuthentication}
          userLoaded={this.userLoaded} 
          userunLoaded={this.userUnLoaded} 
          renderNotAuthenticated={this.NotAuthenticated}
        >
            <div>If you see this you are authenticated.</div>
        </Authenticate>
      )
  }
}

rluders avatar Mar 16 '20 15:03 rluders