Credential.create()

Learn: Credentials

Create a credential.

Signature

Credential.create(data: {*: Any}): <Document>

Description

The Credential.create() method creates a credential.

A credential associates a password with an identity document.

You can use credentials to create tokens as part of an end-user authentication system.

Parameters

Parameter Type Required Description

data

Object

Yes

Object describing the credential.

data fields

Name Type Required Description

document

Document

Yes

Identity document. Must be in a user-defined collection.

Tokens created using the credential are tied to this document. An identity document can only have one credential.

password

String

Password associated with the credential. Typically an end user’s password.

Return value

Type Description

Credential

Document in the Credential system collection. See Credential document definition.

Examples

Credentials.create({
  document: People.byId("372696914650464289"),
  password: "sekret"
})
{
  id: "373081348103995425",
  coll: Credential,
  ts: Time("2023-08-14T23:49:09.650Z"),
  document: People.byId("372696914650464289")
}

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!