"use strict";(()=>{var e={};e.id=3292,e.ids=[3292],e.modules={76102:e=>{e.exports=require("@moduletrace/datasquirel/dist/client")},39383:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/actions/users/user-auth")},65967:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/ejson")},93726:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/numberfy")},30889:e=>{e.exports=require("@moduletrace/datasquirel/dist/package-shared/utils/slugify")},75600:e=>{e.exports=require("next/dist/compiled/next-server/pages-api.runtime.prod.js")},29021:e=>{e.exports=require("fs")},96762:(e,r)=>{Object.defineProperty(r,"M",{enumerable:!0,get:function(){return function e(r,t){return t in r?r[t]:"then"in r&&"function"==typeof r.then?r.then(r=>e(r,t)):"function"==typeof r&&"default"===t?r:void 0}}})},10353:(e,r,t)=>{t.r(r),t.d(r,{config:()=>S,default:()=>p,routeModule:()=>_});var s={};t.r(s),t.d(s,{default:()=>d});var a=t(89947),n=t(2706),o=t(96762),i=t(29021),l=t.n(i),u=t(67619),c=t(69842);async function d(e,r){if("POST"!==e.method)return r.json({msg:"Failed!"});let{user:t,appData:s}=await (0,c.A)(e,r,!0);if(!t)return r.json({success:!1,msg:"Unauthorized"});let{dbFullName:a,dbSlug:n,paradigm:o,platforms:i}=e.body;try{let e=`${process.env.DSQL_USER_DB_SCHEMA_PATH}/user-${t.id}/env.json`;l().existsSync(e)||l().writeFileSync(e,"{}","utf8");let s=JSON.parse(l().readFileSync(e,"utf8")),n=s[a];n||(n={social:[]},s[a]=n);let u=n.social;u=[];for(let e=0;e<i.length;e++){let r=i[e],{clientId:t,clientSecret:s,domain1:a,domain2:n,callbackUrl:l}=r;if(o?.match(/personal/)&&!t?.match(/./))throw Error("Client Id Must be present");if(o?.match(/personal/)&&!s?.match(/./))throw Error("Client Secret Must be present");if(o?.match(/datasquirel/)&&!a?.match(/./))throw Error("Atleast one Domain Must be present");o?.match(/personal/)?u.push({platform:r.platform,paradigm:o,clientId:t,clientSecret:s,callbackUrl:l}):u.push({platform:r.platform,paradigm:o,domain1:a,domain2:n})}n.social=u,l().writeFileSync(e,JSON.stringify(s,null,4),"utf-8"),r.json({success:!0})}catch(e){console.log(e.message),(0,u.A)({component:"/api/addSocialLogin/catch-error",message:e.message,user:t}),r.json({success:!1,msg:e.message})}}let p=(0,o.M)(s,"default"),S=(0,o.M)(s,"config"),_=new a.PagesAPIRouteModule({definition:{kind:n.A.PAGES_API,page:"/api/addSocialLogin",pathname:"/api/addSocialLogin",bundlePath:"",filename:""},userland:s})},55153:(e,r,t)=>{t.d(r,{On:()=>a.a,_n:()=>o}),t(76102);var s=t(65967),a=t.n(s);t(30889);var n=t(93726);let o=t.n(n)()},69842:(e,r,t)=>{t.d(r,{A:()=>o});var s=t(39383),a=t.n(s),n=t(55153);async function o(e,r,t,s){let o=a()({req:e,level:t?"deep":void 0}),i={DSQL_REMOTE_SQL_HOST:process.env.DSQL_REMOTE_SQL_HOST,DSQL_SU_USER_ID:process.env.DSQL_SU_USER_ID,DSQL_HOST_ENV:process.env.DSQL_HOST_ENV,DSQL_HOST:process.env.DSQL_HOST,DSQL_STATIC_HOST:process.env.DSQL_STATIC_HOST,DSQL_GOOGLE_CLIENT_ID:process.env.DSQL_GOOGLE_CLIENT_ID,DSQL_TINY_MCE_API_KEY:process.env.DSQL_TINY_MCE_API_KEY};return s&&o.payload?.id&&(0,n._n)(process.env.DSQL_SU_USER_ID)!==o.payload.id?{user:null,appData:i}:{user:o.payload,appData:i}}},67619:(e,r,t)=>{t.d(r,{A:()=>n});var s=t(29021),a=t.n(s);async function n({user:e,message:r,component:t,noMail:s,req:n}){let o=new Date,i=(()=>{if(!n)return null;try{let e=n.headers["x-forwarded-for"],r=n.headers["x-real-ip"],t=n.headers["cf-connecting-ip"],s=Array.isArray(e)?e[0]:e?.split(",")[0],a=t||s||r||n.socket.remoteAddress;if(!a)return null;return String(a)}catch(e){return null}})();try{let s=`🚀 SERVER ERROR ===========================
Error Message: ${r}
Component: ${t}`;e?.id&&e?.first_name&&e?.last_name&&e?.email&&(s+=`
User Id: ${e?.id}
User Name: ${e?.first_name} ${e?.last_name}
User Email: ${e?.email}`),n?.url&&(s+=`
URL: ${n.url}`),n?.body&&(s+=`
Request Body: ${JSON.stringify(n.body,null,4)}`),i&&(s+=`
IP: ${i}`),s+=`
Date: ${o.toDateString()}
========================================`,a().existsSync("./.tmp/error.log")||a().writeFileSync("./.tmp/error.log","","utf-8");let l=a().readFileSync("./.tmp/error.log","utf-8");a().writeFileSync("./.tmp/error.log",s),a().appendFileSync("./.tmp/error.log",`




${l}`)}catch(e){console.log("Server Error Reporting Error:",e.message)}}},2706:(e,r)=>{Object.defineProperty(r,"A",{enumerable:!0,get:function(){return t}});var t=function(e){return e.PAGES="PAGES",e.PAGES_API="PAGES_API",e.APP_PAGE="APP_PAGE",e.APP_ROUTE="APP_ROUTE",e.IMAGE="IMAGE",e}({})},89947:(e,r,t)=>{e.exports=t(75600)}};var r=require("../../webpack-api-runtime.js");r.C(e);var t=r(r.s=10353);module.exports=t})();