Bugfix
This commit is contained in:
@@ -102,6 +102,8 @@ __webpack_require__.r(__webpack_exports__);
|
||||
/* harmony import */ var _functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1__);
|
||||
/* harmony import */ var _functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(7839);
|
||||
/* harmony import */ var _functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_functions_backend_social_login_handleSocialDb__WEBPACK_IMPORTED_MODULE_2__);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(1007);
|
||||
/* harmony import */ var _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3__);
|
||||
// @ts-check
|
||||
/** # MODULE TRACE
|
||||
======================================================================
|
||||
@@ -115,6 +117,7 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
|
||||
|
||||
|
||||
|
||||
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /**
|
||||
* API handler
|
||||
* ==============================================================================
|
||||
@@ -133,28 +136,16 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
*
|
||||
* @description Send a boolean response
|
||||
*/ try {
|
||||
/**
|
||||
* User auth
|
||||
*
|
||||
* @description Authenticate user
|
||||
*/ const deletedKeys = fs.readFileSync("./apiKeys/deleted.txt", "utf8");
|
||||
/** @type {string} */ // @ts-ignore
|
||||
const { token , clientId , database , additionalFields } = req.body;
|
||||
const authorization = req.headers.authorization;
|
||||
if (deletedKeys.includes(authorization)) {
|
||||
return res.json({
|
||||
success: false,
|
||||
msg: "Key Inactive!"
|
||||
});
|
||||
const apiCred = _package_shared_functions_backend_api_cred__WEBPACK_IMPORTED_MODULE_3___default()({
|
||||
key: authorization,
|
||||
database
|
||||
});
|
||||
if (!apiCred?.user_id) {
|
||||
throw new Error("Api Credentials invalid!");
|
||||
}
|
||||
const userJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(authorization);
|
||||
if (!userJSON) throw new Error("Failed!");
|
||||
const user = JSON.parse(userJSON);
|
||||
const { user_id , full_access , csrf } = user;
|
||||
try {
|
||||
const decryptedCsrfJSON = _package_shared_functions_backend_decrypt__WEBPACK_IMPORTED_MODULE_0___default()(csrf);
|
||||
const decryptedCsrf = JSON.parse(decryptedCsrfJSON || "{}");
|
||||
} catch (error) {}
|
||||
if (!full_access || !csrf) return res.json({
|
||||
if (!apiCred.full_access || !apiCred.sign) return res.json({
|
||||
success: false,
|
||||
msg: "Unauthorized"
|
||||
});
|
||||
@@ -165,8 +156,7 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
* Grab User data
|
||||
*
|
||||
* @description Grab User data
|
||||
*/ const { token , clientId , database , additionalFields } = req.body;
|
||||
const client = new OAuth2Client(clientId);
|
||||
*/ const client = new OAuth2Client(clientId);
|
||||
const ticket = await client.verifyIdToken({
|
||||
idToken: token,
|
||||
audience: clientId
|
||||
@@ -196,7 +186,7 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
* Create new user folder and file
|
||||
*
|
||||
* @description Create new user folder and file
|
||||
*/ const targetDbName = `datasquirel_user_${user_id}_${database}`;
|
||||
*/ const targetDbName = `datasquirel_user_${apiCred.user_id}_${database}`;
|
||||
const { given_name , family_name , email , sub , picture , email_verified } = payload;
|
||||
const payloadObject = {
|
||||
email: email,
|
||||
@@ -228,14 +218,14 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
////////////////////////////////////////
|
||||
res.json({
|
||||
...loggedInGoogleUser,
|
||||
dsqlUserId: user_id
|
||||
dsqlUserId: apiCred.user_id
|
||||
});
|
||||
////////////////////////////////////////
|
||||
} catch (/** @type {any} */ error1) {
|
||||
} catch (/** @type {any} */ error) {
|
||||
////////////////////////////////////////
|
||||
_functions_backend_serverError__WEBPACK_IMPORTED_MODULE_1___default()({
|
||||
component: "/api/user/google-login/main-catch-error",
|
||||
message: error1.message,
|
||||
message: error.message,
|
||||
user: {}
|
||||
});
|
||||
res.json({
|
||||
@@ -256,7 +246,7 @@ const { OAuth2Client } = __webpack_require__(6781);
|
||||
var __webpack_require__ = require("../../../webpack-api-runtime.js");
|
||||
__webpack_require__.C(exports);
|
||||
var __webpack_exec__ = (moduleId) => (__webpack_require__(__webpack_require__.s = moduleId))
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,7547,5886,5338,8326,1311,6926,7487,613,4294,6968], () => (__webpack_exec__(3364)));
|
||||
var __webpack_exports__ = __webpack_require__.X(0, [2224,2163,3017,3403,7547,5886,5338,8326,1311,1007,6926,7487,613,4294,6968], () => (__webpack_exec__(3364)));
|
||||
module.exports = __webpack_exports__;
|
||||
|
||||
})();
|
||||
Reference in New Issue
Block a user