solid-client-authn-js icon indicating copy to clipboard operation
solid-client-authn-js copied to clipboard

Provide session or sessionInfo to onLogin callback

Open Vinnl opened this issue 5 years ago • 0 comments

Search terms you've used

session, sessionInfo, onLogin

Impacted environment

In which environment would the proposed feature apply ?

  • [x] The browser
  • [x] Node.js (Though mostly the browser)
  • [ ] Other (please specify): ...
  • [ ] I'm not sure.

Feature suggestion

When using the default session, it would be nice if I could access the sessionInfo, or possibly even the entire session, from the callback handler passed to onLogin.

Expected functionality/enhancement

import { onLogin } from "@inrupt/solid-client-authn-browser";

onLogin((sessionInfo) => {
    console.log("This should be a safe operation:", sessionInfo.webId);
});

Actual functionality/enhancement

Currently you have to add another call to getDefaultSession() in the callback, and a type checker cannot statically verify that its webId property is set and isLoggedIn is true.

Use Cases

I've got a central place in my app that keeps track of the user's session, and I update it whenever a login or logout event is thrown.

Additional information

N/A

Vinnl avatar Feb 12 '21 15:02 Vinnl