store/Auth

Methods

addAuthListener(listener)

Description:
  • Adds an authentication listener, it will be notified of login and logout events.

Source:
Parameters:
Name Type Description
listener function

getAuthCookie() → {string|undefined}

Description:
  • The session cookie from the last login or setAuthCookie, Node only. Use it together with setAuthCookie to keep a session across processes.

Source:
Returns:

"auth_token="

Type
string | undefined

(async) getUserEntry(forceLookup) → {Promise.<Entry>}

Source:
Parameters:
Name Type Default Description
forceLookup boolean false
Returns:

on success the entry for the currently signed in user is provided.

Type
Promise.<Entry>

(async) getUserInfo(forceLookup) → {Promise.<EntryInfo>}

Description:
  • Yields information about who currently is authenticated against the EntryStore repository.

Source:
See:
  • auth
  • logout
Parameters:
Name Type Default Description
forceLookup boolean false
Returns:
  • upon success an object containing attributes "user" being the username, "id" of the user entry, and "homecontext" being the entry-id of the home context is provided.
Type
Promise.<EntryInfo>

(async) login(user, password, maxAge) → {Promise}

Description:
  • Authenticate using credentials containing a user, a password and an optional maxAge given in seconds. In Node, the login is refused without a request when the repository is on plain http and not a loopback address (localhost, 127.0.0.1 or [::1]).

Source:
Parameters:
Name Type Description
user string
password string
maxAge number
Returns:
Type
Promise

(async) logout() → {Promise.<{user, id}>}

Description:
  • Logout the currently authorized user.

Source:
Returns:

The guest user info

Type
Promise.<{user, id}>

messageListeners(topic, obj)

Source:
Parameters:
Name Type Description
topic string
obj object

removeAuthListener(listener)

Description:
  • Removes an authentication listener

Source:
Parameters:
Name Type Description
listener function

setAuthCookie(cookie)

Description:
  • Restores a session from a cookie returned by getAuthCookie, Node only. The cookie is only sent to the repository's origin. Nothing is requested; the user is looked up on the next getUserInfo, call getUserInfo(true) to check that the session is still valid.

Source:
Parameters:
Name Type Description
cookie string

"auth_token="

Throws:

if the repository is on plain http and not a loopback address (localhost, 127.0.0.1 or [::1])

Type
Error