Skip to content

Is Authenticated

Returns True if the user is authenticated. False otherwise.

Usage

Node.js

const isLoggedIn = await provider.auth.isAuthenticated('<token>');

Next.js

const isLoggedIn = await provider.auth.isAuthenticated();

Express.js Requires useProductFlame middleware.

app.get('/protected-route', async (req, res) => {
if (await req.auth.isAuthenticated()) {
// ...
}
});

Arguments

NameTypeDescription
tokenOrReqstring | IncomingMessageRequired (Node.js only). The session token string, or the HTTP request object (to extract the token automatically).

Response

Type: Promise<boolean>

Returns true if the session is valid, false otherwise.

Errors

  • UNKNOWN_ERROR: An unknown error has occured.