Updates
This commit is contained in:
+17
-5
@@ -31,6 +31,7 @@ type Param = {
|
||||
user_id?: string | number;
|
||||
skipPassword?: boolean;
|
||||
useLocal?: boolean;
|
||||
debug?: boolean;
|
||||
skipWriteAuthFile?: boolean;
|
||||
apiUserID?: string | number;
|
||||
dbUserId?: string | number;
|
||||
@@ -57,6 +58,7 @@ export default async function loginUser({
|
||||
apiUserID,
|
||||
skipWriteAuthFile,
|
||||
dbUserId,
|
||||
debug,
|
||||
}: Param): Promise<APILoginFunctionReturn> {
|
||||
const grabedHostNames = grabHostNames();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
@@ -152,6 +154,7 @@ export default async function loginUser({
|
||||
token,
|
||||
useLocal,
|
||||
dbUserId,
|
||||
debug,
|
||||
});
|
||||
} else {
|
||||
httpResponse = await new Promise((resolve, reject) => {
|
||||
@@ -210,11 +213,10 @@ export default async function loginUser({
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Make https request
|
||||
*
|
||||
* @description make a request to datasquirel.com
|
||||
*/
|
||||
if (debug) {
|
||||
console.log(`loginUser:httpResponse:`, httpResponse);
|
||||
}
|
||||
|
||||
if (httpResponse?.success) {
|
||||
let encryptedPayload = encrypt({
|
||||
data: JSON.stringify(httpResponse.payload),
|
||||
@@ -245,10 +247,20 @@ export default async function loginUser({
|
||||
const authKeyName = cookieNames.keyCookieName;
|
||||
const csrfName = cookieNames.csrfCookieName;
|
||||
|
||||
if (debug) {
|
||||
console.log(`loginUser:authKeyName:`, authKeyName);
|
||||
console.log(`loginUser:csrfName:`, csrfName);
|
||||
console.log(`loginUser:encryptedPayload:`, encryptedPayload);
|
||||
}
|
||||
|
||||
response?.setHeader("Set-Cookie", [
|
||||
`${authKeyName}=${encryptedPayload};samesite=strict;path=/;HttpOnly=true;Secure=true`,
|
||||
`${csrfName}=${httpResponse.payload?.csrf_k};samesite=strict;path=/;HttpOnly=true`,
|
||||
]);
|
||||
|
||||
if (debug) {
|
||||
console.log(`loginUser:Response Sent!`);
|
||||
}
|
||||
}
|
||||
|
||||
return httpResponse;
|
||||
|
||||
Reference in New Issue
Block a user