fastify-xauth-nile
signIn(request, creds)
Sign in with email/password (credentials provider) or an OAuth provider name, using the request cookies.
signIn(request, creds)
Request-scoped wrapper around nile.auth.signIn. An object { email, password } uses the credentials provider (Nile sign-in). A string is a provider name (google, email, …).
The HTTP route POST /api/auth/signin is also mounted. Form posts need a CSRF cookie plus csrfToken in the body.
Signature
instance.signIn(
request: FastifyRequest,
credentials: { email: string; password: string },
rawResponse?: boolean
): Promise<any>
instance.signIn(
request: FastifyRequest,
provider: string,
payload?: object,
rawResponse?: boolean
): Promise<any>
Params
| Name | Type | Required | Description |
|---|---|---|---|
request | FastifyRequest | Yes | Supplies cookies/headers for context |
credentials or provider | { email, password } or string | Yes | Credentials object or provider name |
payload | object | No | Extra fields when using a provider name |
rawResponse | boolean | No | Return the raw Response when the SDK does |
Examples
const auth = fastify.xAuthNile.default;
fastify.post("/internal/login", async (request) =>
auth.signIn(request, {
email: request.body.email,
password: request.body.password,
})
);
await auth.signIn(request, "google");
Clients can also POST /api/auth/signin after GET /api/auth/csrf.
See also
AI Context
package: "@xenterprises/fastify-xauth-nile"
method: fastify.xAuthNile.get(name).signIn(request, creds)
use-when: credentials sign-in { email, password } or provider name; HTTP alternative POST /api/auth/signin
usage: await auth.signIn(request, { email, password })
