solid-contrib / solid-auth-fetcher

A client library for authenticating with Solid
Other
2 stars 6 forks source link

onSession does not work with popup workflow #23

Open josephguillaume opened 3 years ago

josephguillaume commented 3 years ago

The "session" event is emitted by handleRedirect, which is never called in the main window with the popup workflow. The callback provided to onSession is therefore never called.

https://github.com/solid/solid-auth-fetcher/blob/877dd07e8a0ecd00121414b21d1aeffbb72660d0/src/AuthFetcher.ts#L121

One option would be to emit a "session" event after the session is created in PopUpLoginHandler https://github.com/solid/solid-auth-fetcher/blob/877dd07e8a0ecd00121414b21d1aeffbb72660d0/src/login/popUp/PopUpLoginHandler.ts#L73

As a workaround, when using the popup workflow, the onSession callback can be called on completion of login, e.g.

solidAuthFetcher.login({
      oidcIssuer: "https://identityProvider.com",
      popUp: true,
      popUpRedirectPath: "/popup.html"
    }).then( session => console.log(session.webId)  )