Updates
This commit is contained in:
+2
-11
@@ -1,14 +1,5 @@
|
||||
import { AddUserFunctionReturn, UserDataPayload } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database: string;
|
||||
payload: UserDataPayload;
|
||||
encryptionKey?: string;
|
||||
useLocal?: boolean;
|
||||
verify?: boolean;
|
||||
};
|
||||
import { AddUserParams, APIResponseObject } from "../../types";
|
||||
/**
|
||||
* # Add User to Database
|
||||
*/
|
||||
export default function addUser({ key, payload, database, encryptionKey, useLocal, verify, }: Param): Promise<AddUserFunctionReturn>;
|
||||
export {};
|
||||
export default function addUser({ apiKey, payload, database, encryptionKey, useLocal, verify, apiVersion, dsqlUserID, }: AddUserParams): Promise<APIResponseObject>;
|
||||
|
||||
+20
-44
@@ -15,64 +15,40 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = addUser;
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_create_user_1 = __importDefault(require("../../functions/api/users/api-create-user"));
|
||||
const grab_api_path_1 = __importDefault(require("../../utils/backend/users/grab-api-path"));
|
||||
const query_dsql_api_1 = __importDefault(require("../../functions/api/query-dsql-api"));
|
||||
/**
|
||||
* # Add User to Database
|
||||
*/
|
||||
function addUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, database, encryptionKey, useLocal, verify, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ apiKey, payload, database, encryptionKey, useLocal, verify, apiVersion = "v1", dsqlUserID, }) {
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
const apiAddUserParams = {
|
||||
database,
|
||||
encryptionKey,
|
||||
payload,
|
||||
verify,
|
||||
dsqlUserID,
|
||||
};
|
||||
if (useLocal) {
|
||||
return yield (0, api_create_user_1.default)({
|
||||
database,
|
||||
encryptionKey,
|
||||
payload,
|
||||
verify,
|
||||
});
|
||||
return yield (0, api_create_user_1.default)(apiAddUserParams);
|
||||
}
|
||||
/**
|
||||
* Make https request
|
||||
*
|
||||
* @description make a request to datasquirel.com
|
||||
*/
|
||||
const httpResponse = yield new Promise((resolve, reject) => {
|
||||
const reqPayload = JSON.stringify({
|
||||
payload,
|
||||
const httpResponse = yield (0, query_dsql_api_1.default)({
|
||||
path: (0, grab_api_path_1.default)({
|
||||
paradigm: "auth",
|
||||
action: "signup",
|
||||
database,
|
||||
encryptionKey,
|
||||
});
|
||||
const httpsRequest = scheme.request({
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": Buffer.from(reqPayload).length,
|
||||
Authorization: key ||
|
||||
process.env.DSQL_FULL_ACCESS_API_KEY ||
|
||||
process.env.DSQL_API_KEY,
|
||||
},
|
||||
port,
|
||||
hostname: host,
|
||||
path: ``,
|
||||
},
|
||||
/**
|
||||
* Callback Function
|
||||
*
|
||||
* @description https request callback
|
||||
*/
|
||||
(response) => {
|
||||
var str = "";
|
||||
response.on("data", function (chunk) {
|
||||
str += chunk;
|
||||
});
|
||||
response.on("end", function () {
|
||||
resolve(JSON.parse(str));
|
||||
});
|
||||
response.on("error", (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
httpsRequest.write(reqPayload);
|
||||
httpsRequest.end();
|
||||
apiVersion,
|
||||
}),
|
||||
apiKey,
|
||||
body: apiAddUserParams,
|
||||
method: "POST",
|
||||
});
|
||||
return httpResponse;
|
||||
});
|
||||
|
||||
+2
-2
@@ -1,6 +1,6 @@
|
||||
import { UpdateUserFunctionReturn } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
apiKey?: string;
|
||||
database: string;
|
||||
deletedUserId: string | number;
|
||||
useLocal?: boolean;
|
||||
@@ -9,5 +9,5 @@ type Param = {
|
||||
/**
|
||||
* # Update User
|
||||
*/
|
||||
export default function deleteUser({ key, database, deletedUserId, useLocal, apiVersion, }: Param): Promise<UpdateUserFunctionReturn>;
|
||||
export default function deleteUser({ apiKey, database, deletedUserId, useLocal, apiVersion, }: Param): Promise<UpdateUserFunctionReturn>;
|
||||
export {};
|
||||
|
||||
+13
-5
@@ -15,11 +15,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = deleteUser;
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_delete_user_1 = __importDefault(require("../../functions/api/users/api-delete-user"));
|
||||
const grab_api_path_1 = __importDefault(require("../../utils/backend/users/grab-api-path"));
|
||||
/**
|
||||
* # Update User
|
||||
*/
|
||||
function deleteUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, database, deletedUserId, useLocal, apiVersion = "v1", }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ apiKey, database, deletedUserId, useLocal, apiVersion = "v1", }) {
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
if (useLocal) {
|
||||
@@ -38,18 +39,25 @@ function deleteUser(_a) {
|
||||
database,
|
||||
deletedUserId,
|
||||
});
|
||||
const finalAPIKey = apiKey ||
|
||||
process.env.DSQL_API_KEY ||
|
||||
process.env.DSQL_FULL_ACCESS_API_KEY;
|
||||
const httpsRequest = scheme.request({
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": Buffer.from(reqPayload).length,
|
||||
Authorization: process.env.DSQL_FULL_ACCESS_API_KEY ||
|
||||
process.env.DSQL_API_KEY ||
|
||||
key,
|
||||
Authorization: finalAPIKey,
|
||||
},
|
||||
port,
|
||||
hostname: host,
|
||||
path: `/api/${apiVersion}/users/${database}/${deletedUserId}`,
|
||||
path: (0, grab_api_path_1.default)({
|
||||
paradigm: "auth",
|
||||
action: "delete",
|
||||
database,
|
||||
apiVersion,
|
||||
userID: deletedUserId,
|
||||
}),
|
||||
},
|
||||
/**
|
||||
* Callback Function
|
||||
|
||||
+2
-11
@@ -1,14 +1,5 @@
|
||||
import { GetUserFunctionReturn } from "../../types";
|
||||
type Param = {
|
||||
key: string;
|
||||
database: string;
|
||||
userId: number;
|
||||
fields?: string[];
|
||||
useLocal?: boolean;
|
||||
apiVersion?: string;
|
||||
};
|
||||
import { GetUserFunctionReturn, GetUserParams } from "../../types";
|
||||
/**
|
||||
* # Get User
|
||||
*/
|
||||
export default function getUser({ key, userId, database, fields, useLocal, apiVersion, }: Param): Promise<GetUserFunctionReturn>;
|
||||
export {};
|
||||
export default function getUser({ apiKey, userId, database, fields, useLocal, apiVersion, dbUserId, selectAll, }: GetUserParams): Promise<GetUserFunctionReturn>;
|
||||
|
||||
+23
-15
@@ -15,11 +15,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = getUser;
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_get_user_1 = __importDefault(require("../../functions/api/users/api-get-user"));
|
||||
const grab_api_path_1 = __importDefault(require("../../utils/backend/users/grab-api-path"));
|
||||
/**
|
||||
* # Get User
|
||||
*/
|
||||
function getUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, userId, database, fields, useLocal, apiVersion = "v1", }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ apiKey, userId, database, fields, useLocal, apiVersion = "v1", dbUserId, selectAll, }) {
|
||||
/**
|
||||
* Initialize
|
||||
*/
|
||||
@@ -40,19 +41,17 @@ function getUser(_a) {
|
||||
"date_updated_timestamp",
|
||||
];
|
||||
const updatedFields = fields && fields[0] ? [...defaultFields, ...fields] : defaultFields;
|
||||
const reqPayload = JSON.stringify({
|
||||
userId,
|
||||
database,
|
||||
fields: [...new Set(updatedFields)],
|
||||
});
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
const getUserParams = {
|
||||
userId,
|
||||
fields: [...new Set(updatedFields)],
|
||||
database,
|
||||
dbUserId,
|
||||
selectAll,
|
||||
};
|
||||
if (useLocal) {
|
||||
return yield (0, api_get_user_1.default)({
|
||||
userId,
|
||||
fields: [...new Set(updatedFields)],
|
||||
dbFullName: database,
|
||||
});
|
||||
return yield (0, api_get_user_1.default)(getUserParams);
|
||||
}
|
||||
/**
|
||||
* Make https request
|
||||
@@ -60,18 +59,27 @@ function getUser(_a) {
|
||||
* @description make a request to datasquirel.com
|
||||
*/
|
||||
const httpResponse = yield new Promise((resolve, reject) => {
|
||||
const reqPayload = JSON.stringify(getUserParams);
|
||||
const finalAPIKey = apiKey ||
|
||||
process.env.DSQL_API_KEY ||
|
||||
process.env.DSQL_FULL_ACCESS_API_KEY ||
|
||||
process.env.DSQL_READ_ONLY_API_KEY;
|
||||
const httpsRequest = scheme.request({
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": Buffer.from(reqPayload).length,
|
||||
Authorization: key ||
|
||||
process.env.DSQL_FULL_ACCESS_API_KEY ||
|
||||
process.env.DSQL_API_KEY,
|
||||
Authorization: finalAPIKey,
|
||||
},
|
||||
port,
|
||||
hostname: host,
|
||||
path: `/api/${apiVersion}/users/${database}/${userId}`,
|
||||
path: (0, grab_api_path_1.default)({
|
||||
paradigm: "auth",
|
||||
action: "get",
|
||||
database,
|
||||
apiVersion,
|
||||
userID: userId,
|
||||
}),
|
||||
},
|
||||
/**
|
||||
* Callback Function
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { APILoginFunctionReturn, LoginUserParam } from "../../types";
|
||||
import { APIResponseObject, DATASQUIREL_LoggedInUser, LoginUserParam } from "../../types";
|
||||
/**
|
||||
* # Login A user
|
||||
*/
|
||||
export default function loginUser({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, user_id, skipPassword, apiUserID, skipWriteAuthFile, dbUserId, debug, cleanupTokens, secureCookie, request, useLocal, }: LoginUserParam): Promise<APILoginFunctionReturn>;
|
||||
export default function loginUser<T extends DATASQUIREL_LoggedInUser = DATASQUIREL_LoggedInUser>({ apiKey, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, skipPassword, apiUserID, skipWriteAuthFile, dbUserId, debug, cleanupTokens, secureCookie, useLocal, apiVersion, }: LoginUserParam): Promise<APIResponseObject<T | null>>;
|
||||
|
||||
+35
-75
@@ -14,20 +14,22 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = loginUser;
|
||||
const encrypt_1 = __importDefault(require("../../functions/dsql/encrypt"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_login_1 = __importDefault(require("../../functions/api/users/api-login"));
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../../functions/backend/cookies/get-auth-cookie-names"));
|
||||
const write_auth_files_1 = require("../../functions/backend/auth/write-auth-files");
|
||||
const debug_log_1 = __importDefault(require("../../utils/logging/debug-log"));
|
||||
const grab_cookie_expirt_date_1 = __importDefault(require("../../utils/grab-cookie-expirt-date"));
|
||||
const grab_api_path_1 = __importDefault(require("../../utils/backend/users/grab-api-path"));
|
||||
const query_dsql_api_1 = __importDefault(require("../../functions/api/query-dsql-api"));
|
||||
function debugFn(log, label) {
|
||||
(0, debug_log_1.default)({ log, addTime: true, title: "loginUser", label });
|
||||
}
|
||||
/**
|
||||
* # Login A user
|
||||
*/
|
||||
function loginUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, user_id, skipPassword, apiUserID, skipWriteAuthFile, dbUserId, debug, cleanupTokens, secureCookie, request, useLocal, }) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ apiKey, payload, database, additionalFields, response, encryptionKey, encryptionSalt, email_login, email_login_code, temp_code_field, token, skipPassword, apiUserID, skipWriteAuthFile, dbUserId, debug, cleanupTokens, secureCookie, useLocal, apiVersion = "v1", }) {
|
||||
var _b, _c;
|
||||
const grabedHostNames = (0, grab_host_names_1.default)({ userId: user_id || apiUserID });
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
const COOKIE_EXPIRY_DATE = (0, grab_cookie_expirt_date_1.default)();
|
||||
const defaultTempLoginFieldName = "temp_login_code";
|
||||
const emailLoginTempCodeFieldName = email_login
|
||||
@@ -37,9 +39,6 @@ function loginUser(_a) {
|
||||
: undefined;
|
||||
const finalEncryptionKey = encryptionKey || process.env.DSQL_ENCRYPTION_PASSWORD;
|
||||
const finalEncryptionSalt = encryptionSalt || process.env.DSQL_ENCRYPTION_SALT;
|
||||
function debugFn(log, label) {
|
||||
(0, debug_log_1.default)({ log, addTime: true, title: "loginUser", label });
|
||||
}
|
||||
if (!(finalEncryptionKey === null || finalEncryptionKey === void 0 ? void 0 : finalEncryptionKey.match(/.{8,}/))) {
|
||||
console.log("Encryption key is invalid");
|
||||
return {
|
||||
@@ -56,93 +55,54 @@ function loginUser(_a) {
|
||||
msg: "Encryption salt is invalid",
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Check required fields
|
||||
*
|
||||
* @description Check required fields
|
||||
*/
|
||||
// const isEmailValid = await validateEmail({ email: payload.email });
|
||||
// if (!payload.email) {
|
||||
// return {
|
||||
// success: false,
|
||||
// payload: null,
|
||||
// msg: isEmailValid.message,
|
||||
// };
|
||||
// }
|
||||
/**
|
||||
* Initialize HTTP response variable
|
||||
*/
|
||||
let httpResponse = {
|
||||
success: false,
|
||||
};
|
||||
const apiLoginParams = {
|
||||
database,
|
||||
email: payload.email,
|
||||
username: payload.username,
|
||||
password: payload.password,
|
||||
skipPassword,
|
||||
encryptionKey: finalEncryptionKey,
|
||||
additionalFields,
|
||||
email_login,
|
||||
email_login_code,
|
||||
email_login_field: emailLoginTempCodeFieldName,
|
||||
token,
|
||||
dbUserId,
|
||||
debug,
|
||||
};
|
||||
/**
|
||||
* Check for local DB settings
|
||||
*
|
||||
* @description Look for local db settings in `.env` file and by pass the http request if available
|
||||
*/
|
||||
if (useLocal) {
|
||||
httpResponse = yield (0, api_login_1.default)({
|
||||
database,
|
||||
email: payload.email,
|
||||
username: payload.username,
|
||||
password: payload.password,
|
||||
skipPassword,
|
||||
encryptionKey: finalEncryptionKey,
|
||||
additionalFields,
|
||||
email_login,
|
||||
email_login_code,
|
||||
email_login_field: emailLoginTempCodeFieldName,
|
||||
token,
|
||||
dbUserId,
|
||||
debug,
|
||||
});
|
||||
httpResponse = yield (0, api_login_1.default)(apiLoginParams);
|
||||
}
|
||||
else {
|
||||
httpResponse = yield new Promise((resolve, reject) => {
|
||||
const reqPayload = {
|
||||
encryptionKey: finalEncryptionKey,
|
||||
payload,
|
||||
httpResponse = yield (0, query_dsql_api_1.default)({
|
||||
path: (0, grab_api_path_1.default)({
|
||||
paradigm: "auth",
|
||||
action: "login",
|
||||
database,
|
||||
additionalFields,
|
||||
email_login,
|
||||
email_login_code,
|
||||
email_login_field: emailLoginTempCodeFieldName,
|
||||
token,
|
||||
skipPassword: skipPassword,
|
||||
dbUserId: dbUserId || 0,
|
||||
};
|
||||
const reqPayloadJSON = JSON.stringify(reqPayload);
|
||||
const httpsRequest = scheme.request({
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": Buffer.from(reqPayloadJSON).length,
|
||||
Authorization: key ||
|
||||
process.env.DSQL_FULL_ACCESS_API_KEY ||
|
||||
process.env.DSQL_API_KEY,
|
||||
},
|
||||
port,
|
||||
hostname: host,
|
||||
path: `/api/user/${user_id || grabedHostNames.user_id}/login-user`,
|
||||
}, (res) => {
|
||||
var str = "";
|
||||
res.on("data", function (chunk) {
|
||||
str += chunk;
|
||||
});
|
||||
res.on("end", function () {
|
||||
resolve(JSON.parse(str));
|
||||
});
|
||||
res.on("error", (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
httpsRequest.write(reqPayloadJSON);
|
||||
httpsRequest.end();
|
||||
apiVersion,
|
||||
}),
|
||||
apiKey,
|
||||
body: apiLoginParams,
|
||||
method: "POST",
|
||||
});
|
||||
}
|
||||
if (debug) {
|
||||
debugFn(httpResponse, "httpResponse");
|
||||
}
|
||||
/**
|
||||
* # Send Response
|
||||
*/
|
||||
if (httpResponse === null || httpResponse === void 0 ? void 0 : httpResponse.success) {
|
||||
let encryptedPayload = (0, encrypt_1.default)({
|
||||
data: JSON.stringify(httpResponse.payload),
|
||||
@@ -158,7 +118,7 @@ function loginUser(_a) {
|
||||
}
|
||||
const cookieNames = (0, get_auth_cookie_names_1.default)({
|
||||
database,
|
||||
userId: grabedHostNames.user_id,
|
||||
userId: apiUserID,
|
||||
});
|
||||
if (httpResponse.csrf && !skipWriteAuthFile) {
|
||||
(0, write_auth_files_1.writeAuthFile)(httpResponse.csrf, JSON.stringify(httpResponse.payload), cleanupTokens && ((_b = httpResponse.payload) === null || _b === void 0 ? void 0 : _b.id)
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ function logoutUser({ response, database, dsqlUserId, encryptedUserString, reque
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
catch ( /** @type {any} */error) {
|
||||
catch (error) {
|
||||
console.log("Error getting decrypted User JSON to logout:", error.message);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
@@ -1,20 +0,0 @@
|
||||
import http from "http";
|
||||
import { APILoginFunctionReturn } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database?: string;
|
||||
response?: http.ServerResponse;
|
||||
request?: http.IncomingMessage;
|
||||
level?: "deep" | "normal";
|
||||
encryptionKey?: string;
|
||||
encryptionSalt?: string;
|
||||
additionalFields?: string[];
|
||||
encryptedUserString?: string;
|
||||
user_id?: string | number;
|
||||
secureCookie?: boolean;
|
||||
};
|
||||
/**
|
||||
* # Reauthorize User
|
||||
*/
|
||||
export default function reauthUser({ key, database, response, request, level, encryptionKey, encryptionSalt, additionalFields, encryptedUserString, user_id, secureCookie, }: Param): Promise<APILoginFunctionReturn>;
|
||||
export {};
|
||||
-179
@@ -1,179 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = reauthUser;
|
||||
const user_auth_1 = __importDefault(require("./user-auth"));
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const login_user_1 = __importDefault(require("./login-user"));
|
||||
/**
|
||||
* # Reauthorize User
|
||||
*/
|
||||
function reauthUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, database, response, request, level, encryptionKey, encryptionSalt, additionalFields, encryptedUserString, user_id, secureCookie, }) {
|
||||
var _b;
|
||||
/**
|
||||
* Check Encryption Keys
|
||||
*
|
||||
* @description Check Encryption Keys
|
||||
*/
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
// const { host, port, scheme } = grabedHostNames;
|
||||
// const COOKIE_EXPIRY_DATE = grabCookieExpiryDate();
|
||||
const finalEncryptionKey = encryptionKey || process.env.DSQL_ENCRYPTION_PASSWORD;
|
||||
const finalEncryptionSalt = encryptionSalt || process.env.DSQL_ENCRYPTION_SALT;
|
||||
const existingUser = (0, user_auth_1.default)({
|
||||
database,
|
||||
encryptionKey: finalEncryptionKey,
|
||||
encryptionSalt: finalEncryptionSalt,
|
||||
level,
|
||||
request,
|
||||
encryptedUserString,
|
||||
});
|
||||
if (!((_b = existingUser === null || existingUser === void 0 ? void 0 : existingUser.payload) === null || _b === void 0 ? void 0 : _b.id)) {
|
||||
return {
|
||||
success: false,
|
||||
payload: null,
|
||||
msg: "Cookie Credentials Invalid",
|
||||
};
|
||||
}
|
||||
return yield (0, login_user_1.default)({
|
||||
database: database || "",
|
||||
payload: {
|
||||
email: existingUser.payload.email,
|
||||
},
|
||||
additionalFields,
|
||||
skipPassword: true,
|
||||
response,
|
||||
request,
|
||||
user_id,
|
||||
secureCookie,
|
||||
key,
|
||||
});
|
||||
/**
|
||||
* Initialize HTTP response variable
|
||||
*/
|
||||
let httpResponse;
|
||||
/**
|
||||
* Check for local DB settings
|
||||
*
|
||||
* @description Look for local db settings in `.env` file and by pass the http request if available
|
||||
*/
|
||||
// const { DSQL_DB_HOST, DSQL_DB_USERNAME, DSQL_DB_PASSWORD, DSQL_DB_NAME } =
|
||||
// process.env;
|
||||
// if (
|
||||
// DSQL_DB_HOST?.match(/./) &&
|
||||
// DSQL_DB_USERNAME?.match(/./) &&
|
||||
// DSQL_DB_PASSWORD?.match(/./) &&
|
||||
// DSQL_DB_NAME?.match(/./) &&
|
||||
// global.DSQL_USE_LOCAL
|
||||
// ) {
|
||||
// let dbSchema: import("../../types").DSQL_DatabaseSchemaType | undefined;
|
||||
// try {
|
||||
// const localDbSchemaPath = path.resolve(
|
||||
// process.cwd(),
|
||||
// "dsql.schema.json"
|
||||
// );
|
||||
// dbSchema = JSON.parse(fs.readFileSync(localDbSchemaPath, "utf8"));
|
||||
// } catch (error) {}
|
||||
// httpResponse = await apiReauthUser({
|
||||
// existingUser: existingUser.payload,
|
||||
// additionalFields,
|
||||
// });
|
||||
// } else {
|
||||
// /**
|
||||
// * Make https request
|
||||
// *
|
||||
// * @description make a request to datasquirel.com
|
||||
// */
|
||||
// httpResponse = (await new Promise((resolve, reject) => {
|
||||
// const reqPayload = JSON.stringify({
|
||||
// existingUser: existingUser.payload,
|
||||
// database,
|
||||
// additionalFields,
|
||||
// });
|
||||
// const httpsRequest = scheme.request(
|
||||
// {
|
||||
// method: "POST",
|
||||
// headers: {
|
||||
// "Content-Type": "application/json",
|
||||
// "Content-Length": Buffer.from(reqPayload).length,
|
||||
// Authorization:
|
||||
// key ||
|
||||
// process.env.DSQL_FULL_ACCESS_API_KEY ||
|
||||
// process.env.DSQL_API_KEY,
|
||||
// },
|
||||
// port,
|
||||
// hostname: host,
|
||||
// path: `/api/user/${
|
||||
// user_id || grabedHostNames.user_id
|
||||
// }/reauth-user`,
|
||||
// },
|
||||
// /**
|
||||
// * Callback Function
|
||||
// *
|
||||
// * @description https request callback
|
||||
// */
|
||||
// (response) => {
|
||||
// var str = "";
|
||||
// response.on("data", function (chunk) {
|
||||
// str += chunk;
|
||||
// });
|
||||
// response.on("end", function () {
|
||||
// resolve(JSON.parse(str));
|
||||
// });
|
||||
// response.on("error", (err) => {
|
||||
// reject(err);
|
||||
// });
|
||||
// }
|
||||
// );
|
||||
// httpsRequest.write(reqPayload);
|
||||
// httpsRequest.end();
|
||||
// })) as APILoginFunctionReturn;
|
||||
// }
|
||||
// /**
|
||||
// * Make https request
|
||||
// *
|
||||
// * @description make a request to datasquirel.com
|
||||
// */
|
||||
// if (httpResponse?.success) {
|
||||
// let encryptedPayload = encrypt({
|
||||
// data: JSON.stringify(httpResponse.payload),
|
||||
// encryptionKey: finalEncryptionKey,
|
||||
// encryptionSalt: finalEncryptionSalt,
|
||||
// });
|
||||
// const cookieNames = getAuthCookieNames({
|
||||
// database,
|
||||
// userId: user_id || grabedHostNames.user_id,
|
||||
// });
|
||||
// httpResponse["cookieNames"] = cookieNames;
|
||||
// httpResponse["key"] = String(encryptedPayload);
|
||||
// const authKeyName = cookieNames.keyCookieName;
|
||||
// const csrfName = cookieNames.csrfCookieName;
|
||||
// response?.setHeader("Set-Cookie", [
|
||||
// `${authKeyName}=${encryptedPayload};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}${
|
||||
// secureCookie ? ";Secure=true" : ""
|
||||
// }`,
|
||||
// `${csrfName}=${httpResponse.payload?.csrf_k};samesite=strict;path=/;HttpOnly=true;Expires=${COOKIE_EXPIRY_DATE}`,
|
||||
// ]);
|
||||
// if (httpResponse.csrf) {
|
||||
// deleteAuthFile(String(existingUser.payload.csrf_k));
|
||||
// writeAuthFile(
|
||||
// httpResponse.csrf,
|
||||
// JSON.stringify(httpResponse.payload)
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// return httpResponse;
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import { ResetPasswordParams, UpdateUserFunctionReturn } from "../../types";
|
||||
/**
|
||||
* # Reset User Password
|
||||
*/
|
||||
export default function resetPassword(params: ResetPasswordParams): Promise<UpdateUserFunctionReturn>;
|
||||
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = resetPassword;
|
||||
const query_dsql_api_1 = __importDefault(require("../../functions/api/query-dsql-api"));
|
||||
const grab_api_path_1 = __importDefault(require("../../utils/backend/users/grab-api-path"));
|
||||
const api_reset_user_password_1 = __importDefault(require("../../functions/api/users/api-reset-user-password"));
|
||||
/**
|
||||
* # Reset User Password
|
||||
*/
|
||||
function resetPassword(params) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
if (params.useLocal) {
|
||||
return yield (0, api_reset_user_password_1.default)(params);
|
||||
}
|
||||
const httpResponse = yield (0, query_dsql_api_1.default)({
|
||||
path: (0, grab_api_path_1.default)({
|
||||
paradigm: "auth",
|
||||
action: "reset-password",
|
||||
database: params.database,
|
||||
apiVersion: params.apiVersion,
|
||||
}),
|
||||
apiKey: params.apiKey,
|
||||
body: params,
|
||||
method: "POST",
|
||||
});
|
||||
return httpResponse;
|
||||
});
|
||||
}
|
||||
+2
-21
@@ -1,24 +1,5 @@
|
||||
import http from "http";
|
||||
import { SendOneTimeCodeEmailResponse } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database: string;
|
||||
email: string;
|
||||
temp_code_field_name?: string;
|
||||
response?: http.ServerResponse & {
|
||||
[s: string]: any;
|
||||
};
|
||||
mail_domain?: string;
|
||||
mail_username?: string;
|
||||
mail_password?: string;
|
||||
mail_port?: number;
|
||||
sender?: string;
|
||||
user_id?: boolean;
|
||||
extraCookies?: import("../../types").CookieObject[];
|
||||
useLocal?: boolean;
|
||||
};
|
||||
import { APIResponseObject, SendEmailCodeParams } from "../../types";
|
||||
/**
|
||||
* # Send Email Code to a User
|
||||
*/
|
||||
export default function sendEmailCode(params: Param): Promise<SendOneTimeCodeEmailResponse>;
|
||||
export {};
|
||||
export default function sendEmailCode(params: SendEmailCodeParams): Promise<APIResponseObject>;
|
||||
|
||||
+27
-68
@@ -13,89 +13,48 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = sendEmailCode;
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_send_email_code_1 = __importDefault(require("../../functions/api/users/api-send-email-code"));
|
||||
const grab_api_path_1 = __importDefault(require("../../utils/backend/users/grab-api-path"));
|
||||
const query_dsql_api_1 = __importDefault(require("../../functions/api/query-dsql-api"));
|
||||
/**
|
||||
* # Send Email Code to a User
|
||||
*/
|
||||
function sendEmailCode(params) {
|
||||
return __awaiter(this, void 0, void 0, function* () {
|
||||
const { key, email, database, temp_code_field_name, mail_domain, mail_password, mail_username, mail_port, sender, user_id, response, extraCookies, useLocal, } = params;
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
const { apiKey, email, database, temp_code_field_name, mail_domain, mail_password, mail_username, mail_port, sender, response, extraCookies, useLocal, apiVersion, dbUserId, } = params;
|
||||
const defaultTempLoginFieldName = "temp_login_code";
|
||||
const emailLoginTempCodeFieldName = temp_code_field_name
|
||||
? temp_code_field_name
|
||||
: defaultTempLoginFieldName;
|
||||
const emailHtml = `<p>Please use this code to login</p>\n<h2>{{code}}</h2>\n<p>Please note that this code expires after 15 minutes</p>`;
|
||||
console.log("useLocal", useLocal);
|
||||
const apiSendEmailCodeParams = {
|
||||
database,
|
||||
email,
|
||||
email_login_field: emailLoginTempCodeFieldName,
|
||||
html: emailHtml,
|
||||
mail_domain,
|
||||
mail_password,
|
||||
mail_port,
|
||||
mail_username,
|
||||
sender,
|
||||
response,
|
||||
extraCookies,
|
||||
dbUserId,
|
||||
};
|
||||
if (useLocal) {
|
||||
return yield (0, api_send_email_code_1.default)({
|
||||
database,
|
||||
email,
|
||||
email_login_field: emailLoginTempCodeFieldName,
|
||||
html: emailHtml,
|
||||
mail_domain,
|
||||
mail_password,
|
||||
mail_port,
|
||||
mail_username,
|
||||
sender,
|
||||
response,
|
||||
extraCookies,
|
||||
});
|
||||
return yield (0, api_send_email_code_1.default)(apiSendEmailCodeParams);
|
||||
}
|
||||
else {
|
||||
/**
|
||||
* Make https request
|
||||
*
|
||||
* @description make a request to datasquirel.com
|
||||
*
|
||||
* @type {import("../../types").SendOneTimeCodeEmailResponse}
|
||||
*/
|
||||
const httpResponse = yield new Promise((resolve, reject) => {
|
||||
const reqPayload = JSON.stringify({
|
||||
email,
|
||||
const httpResponse = yield (0, query_dsql_api_1.default)({
|
||||
path: (0, grab_api_path_1.default)({
|
||||
paradigm: "auth",
|
||||
action: "send-email-code",
|
||||
database,
|
||||
email_login_field: emailLoginTempCodeFieldName,
|
||||
mail_domain,
|
||||
mail_password,
|
||||
mail_username,
|
||||
mail_port,
|
||||
sender,
|
||||
html: emailHtml,
|
||||
});
|
||||
const httpsRequest = scheme.request({
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": Buffer.from(reqPayload).length,
|
||||
Authorization: key ||
|
||||
process.env.DSQL_FULL_ACCESS_API_KEY ||
|
||||
process.env.DSQL_API_KEY,
|
||||
},
|
||||
port,
|
||||
hostname: host,
|
||||
path: `/api/user/${user_id || grabedHostNames.user_id}/send-email-code`,
|
||||
},
|
||||
/**
|
||||
* Callback Function
|
||||
*
|
||||
* @description https request callback
|
||||
*/
|
||||
(res) => {
|
||||
var str = "";
|
||||
res.on("data", function (chunk) {
|
||||
str += chunk;
|
||||
});
|
||||
res.on("end", function () {
|
||||
resolve(JSON.parse(str));
|
||||
});
|
||||
res.on("error", (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
httpsRequest.write(reqPayload);
|
||||
httpsRequest.end();
|
||||
apiVersion,
|
||||
}),
|
||||
apiKey,
|
||||
body: apiSendEmailCodeParams,
|
||||
method: "POST",
|
||||
});
|
||||
return httpResponse;
|
||||
}
|
||||
|
||||
+5
-13
@@ -1,16 +1,8 @@
|
||||
import { UpdateUserFunctionReturn } from "../../types";
|
||||
type Param = {
|
||||
key?: string;
|
||||
database: string;
|
||||
updatedUserId: string | number;
|
||||
payload: {
|
||||
[s: string]: any;
|
||||
};
|
||||
user_id?: boolean;
|
||||
useLocal?: boolean;
|
||||
};
|
||||
import { UpdateUserFunctionReturn, UpdateUserParams } from "../../types";
|
||||
import { DSQL_DATASQUIREL_USERS } from "../../types/dsql";
|
||||
/**
|
||||
* # Update User
|
||||
*/
|
||||
export default function updateUser({ key, payload, database, user_id, updatedUserId, useLocal, }: Param): Promise<UpdateUserFunctionReturn>;
|
||||
export {};
|
||||
export default function updateUser<T extends DSQL_DATASQUIREL_USERS = DSQL_DATASQUIREL_USERS & {
|
||||
[k: string]: any;
|
||||
}>({ payload, database, updatedUserId, useLocal, apiKey, apiVersion, dbUserId, }: UpdateUserParams<T>): Promise<UpdateUserFunctionReturn>;
|
||||
|
||||
+19
-46
@@ -13,65 +13,38 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = updateUser;
|
||||
const grab_host_names_1 = __importDefault(require("../../utils/grab-host-names"));
|
||||
const api_update_user_1 = __importDefault(require("../../functions/api/users/api-update-user"));
|
||||
const query_dsql_api_1 = __importDefault(require("../../functions/api/query-dsql-api"));
|
||||
const grab_api_path_1 = __importDefault(require("../../utils/backend/users/grab-api-path"));
|
||||
/**
|
||||
* # Update User
|
||||
*/
|
||||
function updateUser(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ key, payload, database, user_id, updatedUserId, useLocal, }) {
|
||||
const grabedHostNames = (0, grab_host_names_1.default)();
|
||||
const { host, port, scheme } = grabedHostNames;
|
||||
return __awaiter(this, arguments, void 0, function* ({ payload, database, updatedUserId, useLocal, apiKey, apiVersion, dbUserId, }) {
|
||||
const updateUserParams = {
|
||||
payload: payload,
|
||||
database,
|
||||
updatedUserId,
|
||||
dbUserId,
|
||||
};
|
||||
if (useLocal) {
|
||||
return yield (0, api_update_user_1.default)({
|
||||
payload: payload,
|
||||
dbFullName: database,
|
||||
updatedUserId,
|
||||
});
|
||||
return yield (0, api_update_user_1.default)(updateUserParams);
|
||||
}
|
||||
/**
|
||||
* Make https request
|
||||
*
|
||||
* @description make a request to datasquirel.com
|
||||
*/
|
||||
const httpResponse = yield new Promise((resolve, reject) => {
|
||||
const reqPayload = JSON.stringify({
|
||||
payload,
|
||||
const httpResponse = yield (0, query_dsql_api_1.default)({
|
||||
path: (0, grab_api_path_1.default)({
|
||||
paradigm: "auth",
|
||||
action: "update",
|
||||
database,
|
||||
updatedUserId,
|
||||
});
|
||||
const httpsRequest = scheme.request({
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
"Content-Length": Buffer.from(reqPayload).length,
|
||||
Authorization: process.env.DSQL_FULL_ACCESS_API_KEY ||
|
||||
process.env.DSQL_API_KEY ||
|
||||
key,
|
||||
},
|
||||
port,
|
||||
hostname: host,
|
||||
path: `/api/user/${user_id || grabedHostNames.user_id}/update-user`,
|
||||
},
|
||||
/**
|
||||
* Callback Function
|
||||
*
|
||||
* @description https request callback
|
||||
*/
|
||||
(response) => {
|
||||
var str = "";
|
||||
response.on("data", function (chunk) {
|
||||
str += chunk;
|
||||
});
|
||||
response.on("end", function () {
|
||||
resolve(JSON.parse(str));
|
||||
});
|
||||
response.on("error", (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
httpsRequest.write(reqPayload);
|
||||
httpsRequest.end();
|
||||
apiVersion,
|
||||
}),
|
||||
apiKey,
|
||||
body: updateUserParams,
|
||||
method: "POST",
|
||||
});
|
||||
return httpResponse;
|
||||
});
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
import http from "http";
|
||||
import { SendOneTimeCodeEmailResponse } from "../../types";
|
||||
type Param = {
|
||||
request?: http.IncomingMessage & {
|
||||
[s: string]: any;
|
||||
};
|
||||
cookieString?: string;
|
||||
email?: string;
|
||||
};
|
||||
/**
|
||||
* # Verify the temp email code sent to the user's email address
|
||||
*/
|
||||
export default function validateTempEmailCode({ request, email, cookieString, }: Param): Promise<SendOneTimeCodeEmailResponse | null>;
|
||||
export {};
|
||||
@@ -1,47 +0,0 @@
|
||||
"use strict";
|
||||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
||||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
||||
return new (P || (P = Promise))(function (resolve, reject) {
|
||||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
||||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
||||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
||||
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
||||
});
|
||||
};
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = validateTempEmailCode;
|
||||
const get_auth_cookie_names_1 = __importDefault(require("../../functions/backend/cookies/get-auth-cookie-names"));
|
||||
const parseCookies_1 = __importDefault(require("../../utils/backend/parseCookies"));
|
||||
const decrypt_1 = __importDefault(require("../../functions/dsql/decrypt"));
|
||||
const ejson_1 = __importDefault(require("../../utils/ejson"));
|
||||
/**
|
||||
* # Verify the temp email code sent to the user's email address
|
||||
*/
|
||||
function validateTempEmailCode(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ request, email, cookieString, }) {
|
||||
try {
|
||||
const keyNames = (0, get_auth_cookie_names_1.default)();
|
||||
const oneTimeCodeCookieName = keyNames.oneTimeCodeName;
|
||||
const cookies = (0, parseCookies_1.default)({ request, cookieString });
|
||||
const encryptedOneTimeCode = cookies[oneTimeCodeCookieName];
|
||||
const encryptedPayload = (0, decrypt_1.default)({
|
||||
encryptedString: encryptedOneTimeCode,
|
||||
});
|
||||
const payload = ejson_1.default.parse(encryptedPayload);
|
||||
if ((payload === null || payload === void 0 ? void 0 : payload.email) && !email) {
|
||||
return payload;
|
||||
}
|
||||
if ((payload === null || payload === void 0 ? void 0 : payload.email) && payload.email === email) {
|
||||
return payload;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
catch (error) {
|
||||
console.log("validateTempEmailCode error:", error.message);
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -1,15 +0,0 @@
|
||||
import { DATASQUIREL_LoggedInUser } from "../../types";
|
||||
type Param = {
|
||||
token: string;
|
||||
encryptionKey: string;
|
||||
encryptionSalt: string;
|
||||
level?: ("deep" | "normal") | null;
|
||||
database: string;
|
||||
};
|
||||
/**
|
||||
* Validate Token
|
||||
* ======================================
|
||||
* @description This Function takes in a encrypted token and returns a user object
|
||||
*/
|
||||
export default function validateToken({ token, encryptionKey, encryptionSalt, }: Param): DATASQUIREL_LoggedInUser | null;
|
||||
export {};
|
||||
@@ -1,63 +0,0 @@
|
||||
"use strict";
|
||||
var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.default = validateToken;
|
||||
const decrypt_1 = __importDefault(require("../../functions/dsql/decrypt"));
|
||||
/**
|
||||
* Validate Token
|
||||
* ======================================
|
||||
* @description This Function takes in a encrypted token and returns a user object
|
||||
*/
|
||||
function validateToken({ token, encryptionKey, encryptionSalt, }) {
|
||||
try {
|
||||
/**
|
||||
* Grab the payload
|
||||
*
|
||||
* @description Grab the payload
|
||||
*/
|
||||
const key = token;
|
||||
/**
|
||||
* Grab the payload
|
||||
*
|
||||
* @description Grab the payload
|
||||
*/
|
||||
let userPayload = (0, decrypt_1.default)({
|
||||
encryptedString: key,
|
||||
encryptionKey,
|
||||
encryptionSalt,
|
||||
});
|
||||
/**
|
||||
* Grab the payload
|
||||
*
|
||||
* @description Grab the payload
|
||||
*/
|
||||
if (!userPayload) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Grab the payload
|
||||
*
|
||||
* @description Grab the payload
|
||||
*/
|
||||
let userObject = JSON.parse(userPayload);
|
||||
if (!userObject.csrf_k) {
|
||||
return null;
|
||||
}
|
||||
/**
|
||||
* Return User Object
|
||||
*
|
||||
* @description Return User Object
|
||||
*/
|
||||
return userObject;
|
||||
}
|
||||
catch (error) {
|
||||
/**
|
||||
* Return User Object
|
||||
*
|
||||
* @description Return User Object
|
||||
*/
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user