Updates
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import http from "http";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import encrypt from "../../functions/dsql/encrypt";
|
||||
@@ -9,40 +8,11 @@ import { writeAuthFile } from "../../functions/backend/auth/write-auth-files";
|
||||
import {
|
||||
APILoginFunctionReturn,
|
||||
DSQL_DatabaseSchemaType,
|
||||
LoginUserParam,
|
||||
PackageUserLoginRequestBody,
|
||||
} from "../../types";
|
||||
import debugLog from "../../utils/logging/debug-log";
|
||||
import grabCookieExpiryDate from "../../utils/grab-cookie-expirt-date";
|
||||
import emailRegexCheck from "../../functions/email/verification/email-regex-test";
|
||||
import emailMxLookup from "../../functions/email/verification/email-mx-lookup";
|
||||
import validateEmail from "../../functions/email/fns/validate-email";
|
||||
|
||||
type Param = {
|
||||
key?: string;
|
||||
database: string;
|
||||
payload: {
|
||||
email?: string;
|
||||
username?: string;
|
||||
password?: string;
|
||||
};
|
||||
additionalFields?: string[];
|
||||
request?: http.IncomingMessage & { [s: string]: any };
|
||||
response?: http.ServerResponse & { [s: string]: any };
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
email_login?: boolean;
|
||||
email_login_code?: string;
|
||||
temp_code_field?: string;
|
||||
token?: boolean;
|
||||
user_id?: string | number;
|
||||
skipPassword?: boolean;
|
||||
debug?: boolean;
|
||||
skipWriteAuthFile?: boolean;
|
||||
apiUserID?: string | number;
|
||||
dbUserId?: string | number;
|
||||
cleanupTokens?: boolean;
|
||||
secureCookie?: boolean;
|
||||
};
|
||||
|
||||
/**
|
||||
* # Login A user
|
||||
@@ -68,7 +38,7 @@ export default async function loginUser({
|
||||
cleanupTokens,
|
||||
secureCookie,
|
||||
request,
|
||||
}: Param): Promise<APILoginFunctionReturn> {
|
||||
}: LoginUserParam): Promise<APILoginFunctionReturn> {
|
||||
const grabedHostNames = grabHostNames({ userId: user_id || apiUserID });
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
const COOKIE_EXPIRY_DATE = grabCookieExpiryDate();
|
||||
@@ -156,7 +126,7 @@ export default async function loginUser({
|
||||
} catch (error) {}
|
||||
|
||||
httpResponse = await apiLoginUser({
|
||||
database: process.env.DSQL_DB_NAME || "",
|
||||
database: database || process.env.DSQL_DB_NAME || "",
|
||||
email: payload.email,
|
||||
username: payload.username,
|
||||
password: payload.password,
|
||||
|
||||
@@ -23,20 +23,24 @@ type Param = {
|
||||
/**
|
||||
* # Send Email Code to a User
|
||||
*/
|
||||
export default async function sendEmailCode({
|
||||
key,
|
||||
email,
|
||||
database,
|
||||
temp_code_field_name,
|
||||
mail_domain,
|
||||
mail_password,
|
||||
mail_username,
|
||||
mail_port,
|
||||
sender,
|
||||
user_id,
|
||||
response,
|
||||
extraCookies,
|
||||
}: Param): Promise<SendOneTimeCodeEmailResponse> {
|
||||
export default async function sendEmailCode(
|
||||
params: Param
|
||||
): Promise<SendOneTimeCodeEmailResponse> {
|
||||
const {
|
||||
key,
|
||||
email,
|
||||
database,
|
||||
temp_code_field_name,
|
||||
mail_domain,
|
||||
mail_password,
|
||||
mail_username,
|
||||
mail_port,
|
||||
sender,
|
||||
user_id,
|
||||
response,
|
||||
extraCookies,
|
||||
} = params;
|
||||
|
||||
const grabedHostNames = grabHostNames();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@ import decrypt from "../../functions/dsql/decrypt";
|
||||
import getAuthCookieNames from "../../functions/backend/cookies/get-auth-cookie-names";
|
||||
import { checkAuthFile } from "../../functions/backend/auth/write-auth-files";
|
||||
import parseCookies from "../../utils/backend/parseCookies";
|
||||
import { AuthenticatedUser } from "../../types";
|
||||
import { AuthenticatedUser, DATASQUIREL_LoggedInUser } from "../../types";
|
||||
import getCsrfHeaderName from "../../actions/get-csrf-header-name";
|
||||
import grabHostNames from "../../utils/grab-host-names";
|
||||
import debugLog from "../../utils/logging/debug-log";
|
||||
@@ -128,8 +128,7 @@ export default function userAuth({
|
||||
};
|
||||
}
|
||||
|
||||
let userObject: import("../../types").DATASQUIREL_LoggedInUser =
|
||||
JSON.parse(userPayloadJSON);
|
||||
let userObject: DATASQUIREL_LoggedInUser = JSON.parse(userPayloadJSON);
|
||||
|
||||
if (debug) {
|
||||
debugLog({
|
||||
|
||||
Reference in New Issue
Block a user