diff --git a/src/controllers/userController.js b/src/controllers/userController.js index a147bc89..c0abc9c7 100644 --- a/src/controllers/userController.js +++ b/src/controllers/userController.js @@ -368,13 +368,19 @@ exports.uploadProfilePicture = async (req, reply) => { exports.logout = async (request, reply) => { - //console.log(request.headers.authorization) - get_user = await userController.getSingleUser(req) - request.headers.authorization = null - //console.log(request.headers.authorization) - // TODO: Clear any session cookies or authentication tokens - - // Send a success response + + // const blacklist = new Set(); + const invalidatedTokens = {}; + const accessToken = request.headers.authorization && request.body.access_token; + // console.log(accessToken) + + // Add the access token to the blacklist + // blacklist.add(accessToken); + // console.log(blacklist.add(accessToken)) + + invalidatedTokens[accessToken] = true; + // console.log(invalidatedTokens[accessToken] = true) + reply.send({ message: 'Logout successful' }) } @@ -390,6 +396,7 @@ exports.logout = async (request, reply) => { + // controller.js const http = require('https'); diff --git a/src/routes/usersRoute.js b/src/routes/usersRoute.js index 21045178..02b7c017 100644 --- a/src/routes/usersRoute.js +++ b/src/routes/usersRoute.js @@ -418,17 +418,20 @@ module.exports = function (fastify, opts, next) { method: "DELETE", url: "/api/logout", schema: { - tags: ["User"], - description: "This is for logout.", - summary: "This is for logout.", - - security: [ - { - basicAuth: [], + description: "This is for logout", + tags: ["Logout"], + summary: "This is for logout", + params: { + type: "object", + properties: { + customerId: { + type: "string", + description: "customerId", + }, + }, + }, }, - ], - }, - //preHandler: validationHandler.logoutHandler, + // preHandler: fastify.auth([fastify.authenticate]), handler: userController.logout, // onResponse: (request,reply) => {validationHandler.resetPassword(request,reply)} });