Skip to content

Login

Login with an email and a password.

Usage

Node.js / Next.js

const response = await provider.auth.login('user@example.com', 'password123');

Express.js Requires useProductFlame middleware.

app.post('/login', async (req, res) => {
// Automatically sets the auth cookie
const response = await req.auth.login('user@example.com', 'password123');
res.json(response);
});

Arguments

NameTypeDescription
emailstringRequired. The user’s email address.
passwordstringRequired. The user’s password.

Response

Type: Promise<{ token: string }>

Returns the session token.

Note: Next.js and Express.js SDKs automatically handle setting the session cookie for you.

Errors

  • INVALID_CREDENTIALS: The email is invalid.
  • INVALID_CREDENTIALS: The password is invalid or the user doesn’t exist.
  • PROVIDER_AUTH_REQUIRED: Please authenticate using a third-party method, as this account was created using one.
  • UNKNOWN_ERROR: An unknown error has occured.