datasquirel/users/logout-user.js

48 lines
1.8 KiB
JavaScript
Raw Normal View History

2023-05-06 11:14:09 +00:00
/**
* ==============================================================================
* Main Function
* ==============================================================================
* @param {Object} response - Http response object
*/
2023-05-09 14:20:53 +00:00
module.exports = function ({ request, response }) {
2023-05-06 11:14:09 +00:00
/**
* Check Encryption Keys
*
* @description Check Encryption Keys
*/
2023-05-09 14:20:53 +00:00
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",
};
}
2023-05-06 11:14:09 +00:00
/** ********************************************** */
/** ********************************************** */
/** ********************************************** */
};
/** ********************************************** */
/** ********************************************** */
/** ********************************************** */