Updates
This commit is contained in:
+12
-4
@@ -14,6 +14,7 @@ type Param = {
|
||||
cookieString?: string;
|
||||
database?: string;
|
||||
dsqlUserId?: string | number;
|
||||
debug?: boolean;
|
||||
};
|
||||
|
||||
type Return = {
|
||||
@@ -32,6 +33,7 @@ export default function logoutUser({
|
||||
encryptedUserString,
|
||||
request,
|
||||
cookieString,
|
||||
debug,
|
||||
}: Param): Return {
|
||||
/**
|
||||
* Check Encryption Keys
|
||||
@@ -44,9 +46,13 @@ export default function logoutUser({
|
||||
userId: dsqlUserId || process.env.DSQL_API_USER_ID,
|
||||
});
|
||||
|
||||
if (debug) {
|
||||
console.log("logoutUser:cookieNames", cookieNames);
|
||||
}
|
||||
|
||||
const authKeyName = cookieNames.keyCookieName;
|
||||
const csrfName = cookieNames.csrfCookieName;
|
||||
const oneTimeCodeName = getAuthCookieNames().oneTimeCodeName;
|
||||
const oneTimeCodeName = cookieNames.oneTimeCodeName;
|
||||
|
||||
const decryptedUserJSON: string | undefined = (() => {
|
||||
try {
|
||||
@@ -75,6 +81,10 @@ export default function logoutUser({
|
||||
}
|
||||
})();
|
||||
|
||||
if (debug) {
|
||||
console.log("logoutUser:decryptedUserJSON", decryptedUserJSON);
|
||||
}
|
||||
|
||||
if (!decryptedUserJSON) throw new Error("Invalid User");
|
||||
|
||||
const userObject = EJSON.parse(
|
||||
@@ -98,7 +108,7 @@ export default function logoutUser({
|
||||
msg: "User Logged Out",
|
||||
cookieNames,
|
||||
};
|
||||
} catch (/** @type {any} */ error: any) {
|
||||
} catch (error: any) {
|
||||
console.log("Logout Error:", error.message);
|
||||
return {
|
||||
success: false,
|
||||
@@ -106,5 +116,3 @@ export default function logoutUser({
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = logoutUser;
|
||||
|
||||
Reference in New Issue
Block a user