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
| Name | Type | Description |
|---|---|---|
tokenOrReq | string | IncomingMessage | Required (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.
GET https://api.productflame.com/v1/auth/isAuthenticated
Request
Headers
{ "Authorization": "<your_secret_api_key>", "Cookie": "__at__=<token>"}Response Format
200 OK (Success)
{ "isAuthenticated": true}500 Internal Server Error
{ "error": "UNKNOWN_ERROR", "message": "An unknown error has occured."}An unknown error has occured.