This commit is contained in:
Benjamin Toby 2024-12-10 15:31:53 +01:00
parent 12a07a4348
commit 5eef6628a4
3 changed files with 8 additions and 9 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@moduletrace/datasquirel", "name": "@moduletrace/datasquirel",
"version": "2.8.5", "version": "2.8.6",
"description": "Cloud-based SQL data management tool", "description": "Cloud-based SQL data management tool",
"main": "index.js", "main": "index.js",
"bin": { "bin": {

View File

@ -8,12 +8,12 @@ export = validateTempEmailCode;
* @param {http.IncomingMessage & Object<string, any>} params.request * @param {http.IncomingMessage & Object<string, any>} params.request
* @param {string} [params.email] * @param {string} [params.email]
* *
* @returns { Promise<boolean>} * @returns { Promise<import("../package-shared/types").SendOneTimeCodeEmailResponse | null>}
*/ */
declare function validateTempEmailCode({ request, email }: { declare function validateTempEmailCode({ request, email }: {
request: http.IncomingMessage & { request: http.IncomingMessage & {
[x: string]: any; [x: string]: any;
}; };
email?: string; email?: string;
}): Promise<boolean>; }): Promise<import("../package-shared/types").SendOneTimeCodeEmailResponse | null>;
import http = require("http"); import http = require("http");

View File

@ -15,7 +15,7 @@ const EJSON = require("../package-shared/utils/ejson");
* @param {http.IncomingMessage & Object<string, any>} params.request * @param {http.IncomingMessage & Object<string, any>} params.request
* @param {string} [params.email] * @param {string} [params.email]
* *
* @returns { Promise<boolean>} * @returns { Promise<import("../package-shared/types").SendOneTimeCodeEmailResponse | null>}
*/ */
async function validateTempEmailCode({ request, email }) { async function validateTempEmailCode({ request, email }) {
try { try {
@ -35,18 +35,17 @@ async function validateTempEmailCode({ request, email }) {
); );
if (payload?.email && !email) { if (payload?.email && !email) {
return true; return payload;
} }
if (payload?.email && payload.email === email) { if (payload?.email && payload.email === email) {
return true; return payload;
} }
return false; return null;
} catch (/** @type {any} */ error) { } catch (/** @type {any} */ error) {
console.log("validateTempEmailCode error:", error.message); console.log("validateTempEmailCode error:", error.message);
return null;
return false;
} }
} }