2025-05-10 02:09:06 +02:00
|
|
|
/*!
|
|
|
|
|
* Copyright (c) 2024 PLANKA Software GmbH
|
|
|
|
|
* Licensed under the Fair Use License: https://github.com/plankanban/planka/blob/master/LICENSE.md
|
|
|
|
|
*/
|
|
|
|
|
|
2025-09-08 16:20:27 +02:00
|
|
|
/**
|
|
|
|
|
* @swagger
|
2025-09-16 15:51:14 +02:00
|
|
|
* /access-tokens/me:
|
2025-09-08 16:20:27 +02:00
|
|
|
* delete:
|
|
|
|
|
* summary: User logout
|
|
|
|
|
* description: Logs out the current user by deleting the session and access token. Clears HTTP-only cookies if present.
|
|
|
|
|
* tags:
|
|
|
|
|
* - Access Tokens
|
2025-09-12 12:17:01 +02:00
|
|
|
* operationId: deleteAccessToken
|
2025-09-08 16:20:27 +02:00
|
|
|
* responses:
|
|
|
|
|
* 200:
|
|
|
|
|
* description: Logout successful
|
|
|
|
|
* content:
|
|
|
|
|
* application/json:
|
|
|
|
|
* schema:
|
|
|
|
|
* type: object
|
|
|
|
|
* required:
|
|
|
|
|
* - item
|
|
|
|
|
* properties:
|
|
|
|
|
* item:
|
|
|
|
|
* type: string
|
|
|
|
|
* description: Revoked access token
|
|
|
|
|
* example: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ4...
|
|
|
|
|
* 401:
|
|
|
|
|
* $ref: '#/components/responses/Unauthorized'
|
2025-11-06 20:56:48 +01:00
|
|
|
* security:
|
|
|
|
|
* - bearerAuth: []
|
2025-09-08 16:20:27 +02:00
|
|
|
*/
|
|
|
|
|
|
2022-09-07 18:39:33 +05:00
|
|
|
module.exports = {
|
|
|
|
|
async fn() {
|
2024-09-01 09:31:04 +02:00
|
|
|
const { currentSession } = this.req;
|
2022-09-07 18:39:33 +05:00
|
|
|
|
2025-05-10 02:09:06 +02:00
|
|
|
await Session.qm.deleteOneById(currentSession.id);
|
2022-09-07 18:39:33 +05:00
|
|
|
|
2024-09-01 09:31:04 +02:00
|
|
|
sails.sockets.leaveAll(`@accessToken:${currentSession.accessToken}`);
|
|
|
|
|
|
|
|
|
|
if (currentSession.httpOnlyToken && !this.req.isSocket) {
|
|
|
|
|
sails.helpers.utils.clearHttpOnlyTokenCookie(this.res);
|
2024-04-09 15:12:46 +02:00
|
|
|
}
|
|
|
|
|
|
2022-09-07 18:39:33 +05:00
|
|
|
return {
|
2024-09-01 09:31:04 +02:00
|
|
|
item: currentSession.accessToken,
|
2022-09-07 18:39:33 +05:00
|
|
|
};
|
|
|
|
|
},
|
|
|
|
|
};
|