Login
Login( identity, param_object )
Description
The Login
function creates an authentication token for the provided
identity
, which can be a Ref or a
Set of refs, based on the password provided in
param_object
.
The authentication token’s secret can be used to connect to Fauna and
execute queries within the database that contains identity
. The
permissions granted to the authentication token can be specified using
Attribute-based access control (ABAC).
Parameters
Argument | Type | Definition and Requirements |
---|---|---|
|
The identity (reference to a document) or identities (set of refs to multiple documents) to authenticate. |
|
|
The |
param_object
Field Name | Field Type | Definition and Requirements | ||
---|---|---|---|---|
|
Optional - a document storing metadata about the token to be created. |
|||
|
The password to authenticate |
|||
|
Optional - A timestamp indicating the authentication token’s time-to-live, which is when the token should be removed. When a token is removed, the token’s existence ceases (temporal queries cannot recover the token) and the associated secret can no longer be used to authenticate.
|
Returns
When authentication is successful, an object containing the authenticated Ref(s) is returned. When authentication fails, an error is returned.
Examples
client.query(
q.Login(
q.Ref(q.Collection('characters'), '181388642114077184'),
{ password: 'abracadabra' },
)
)
.then((ret) => console.log(ret))
{ ref: Ref(id=181388643175236096, collection=Ref(id=tokens)),
ts: 1527279532953934,
document:
Ref(id=181388642114077184, collection=Ref(id=characters, collection=Ref(id=collections))),
secret: 'fnECx5uE8OACAQLCZP7uQAIBF3rvpXoJEzfIrNXEL21PUpib9AE' }
Is this article helpful?
Tell Fauna how the article can be improved:
Visit Fauna's forums
or email docs@fauna.com
Thank you for your feedback!