diff --git a/package.json b/package.json index a121098..c4253c7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "datasquirel", - "version": "1.1.0", + "version": "1.1.1", "description": "Cloud-based SQL data management tool", "main": "index.js", "scripts": { diff --git a/users/logout-user.js b/users/logout-user.js index 2fc2abe..539a389 100644 --- a/users/logout-user.js +++ b/users/logout-user.js @@ -4,22 +4,42 @@ * ============================================================================== * @param {Object} response - Http response object */ -module.exports = function ({ response }) { +module.exports = function ({ request, response }) { /** * Check Encryption Keys * * @description Check Encryption Keys */ - response.setHeader("Set-Cookie", ["datasquirelAuthKey=null;samesite=strict;path=/;HttpOnly=true;Secure=true", "csrf=null;samesite=strict;path=/;HttpOnly=true"]); + try { + const authKeyName = request.cookies.filter((cookie) => cookie.match(/datasquirel_.*_auth_key/))[0]; + const csrfName = request.cookies.filter((cookie) => cookie.match(/datasquirel_.*_csrf/))[0]; + + response.setHeader("Set-Cookie", [`${authKeyName}=null;samesite=strict;path=/;HttpOnly=true;Secure=true`, `${csrfName}=null;samesite=strict;path=/;HttpOnly=true`, `dsqluid=null;samesite=strict;path=/;HttpOnly=true`]); + + /** ********************************************** */ + /** ********************************************** */ + /** ********************************************** */ + + return { + success: true, + payload: "User Logged Out", + }; + + /** ********************************************** */ + /** ********************************************** */ + /** ********************************************** */ + } catch (error) { + console.log(error.message); + + return { + success: false, + payload: "Logout Failed", + }; + } /** ********************************************** */ /** ********************************************** */ /** ********************************************** */ - - return { - success: true, - payload: "User Logged Out", - }; }; /** ********************************************** */