Logout
Logs out a user by invalidating its token.
Usage
Node.js
await provider.auth.logout('<token>');Next.js
await provider.auth.logout();Express.js
Requires useProductFlame middleware.
app.post('/logout', async (req, res) => { await req.auth.logout(); res.json({ message: 'Logged out' });});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<void>
Returns nothing (void) upon success.
Errors
AUTHENTICATION_REQUIRED: User not authenticated.UNKNOWN_ERROR: An unknown error has occured.
POST https://api.productflame.com/v1/auth/logout
Request
Headers
{ "Authorization": "<your_secret_api_key>", "Cookie": "__at__=<token>"}Response Format
200 OK (Success)
{ "message": "ok"}A Set-Cookie header will also be included to clear the session cookie.
401 Unauthorized
{ "error": "AUTHENTICATION_REQUIRED", "message": "User not authenticated"}User not authenticated.
500 Internal Server Error
{ "error": "UNKNOWN_ERROR", "message": "An unknown error has occured."}An unknown error has occured.