How to use the solid-auth-client.currentSession function in solid-auth-client

To help you get started, we’ve selected a few solid-auth-client examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github solid / solid-ui / src / authn / authn.ts View on Github external
export function checkUser (
  setUserCallback?: (me: $rdf.NamedNode | null) => T
): Promise<$rdf.NamedNode | T> {
  // Check to see if already logged in / have the WebID
  const me = defaultTestUser()
  if (me) {
    return Promise.resolve(setUserCallback ? setUserCallback(me) : me)
  }

  // doc = kb.any(doc, ns.link('userMirror')) || doc

  return solidAuthClient
    .currentSession()
    .then(webIdFromSession)
    .catch(err => {
      console.log('Error fetching currentSession:', err)
    })
    .then(webId => {
      // if (webId.startsWith('dns:')) {  // legacy rww.io pseudo-users
      //   webId = null
      // }
      const me = saveUser(webId)

      if (me) {
        console.log(`(Logged in as ${me} by authentication)`)
      }

      return setUserCallback ? setUserCallback(me) : me
github solid / query-ldflex / src / UserPathHandler.js View on Github external
async getWebId() {
    const session = await auth.currentSession();
    if (!session)
      throw new Error('Cannot resolve user path: no user logged in');
    return session.webId;
  }
}
github Eximua / solid-ipfs / src / solid-file-client.js View on Github external
checkSession: async function() { 
    var sess = await solid.currentSession()
    if(!sess){
        this.webId = undefined
        return false;
    }
    this.webId = sess.webId
    return { webId : sess.webId }
},
popupLogin: async function() {
github solid / solid-ui / src / authn / authn.ts View on Github external
box.refresh = function () {
    solidAuthClient.currentSession().then(
      session => {
        if (session && session.webId) {
          me = $rdf.sym(session.webId)
        } else {
          me = null
        }
        if ((me && box.me !== me.uri) || (!me && box.me)) {
          widgets.clearElement(box)
          if (me) {
            box.appendChild(logoutButton(me, options))
          } else {
            box.appendChild(signInOrSignUpBox(dom, setIt, options))
          }
        }
        box.me = me ? me.uri : null
      },

solid-auth-client

Opaquely authenticates solid clients

MIT
Latest version published 3 years ago

Package Health Score

52 / 100
Full package analysis

Similar packages