2024-11-05 11:12:42 +00:00
"use strict" ;
( ( ) => {
var exports = { } ;
exports . id = 4772 ;
exports . ids = [ 4772 ] ;
exports . modules = {
/***/ 5004 :
/***/ ( ( _ _unused _webpack _module , _ _webpack _exports _ _ , _ _webpack _require _ _ ) => {
_ _webpack _require _ _ . r ( _ _webpack _exports _ _ ) ;
/* harmony export */ _ _webpack _require _ _ . d ( _ _webpack _exports _ _ , {
/* harmony export */ "default" : ( ) => ( /* binding */ VerifyEmail ) ,
/* harmony export */ "getServerSideProps" : ( ) => ( /* binding */ getServerSideProps )
/* harmony export */ } ) ;
/* harmony import */ var react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ = _ _webpack _require _ _ ( 997 ) ;
/* harmony import */ var react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ ) ;
/* harmony import */ var react _ _WEBPACK _IMPORTED _MODULE _1 _ _ = _ _webpack _require _ _ ( 6689 ) ;
/* harmony import */ var react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( react _ _WEBPACK _IMPORTED _MODULE _1 _ _ ) ;
/* harmony import */ var next _head _ _WEBPACK _IMPORTED _MODULE _2 _ _ = _ _webpack _require _ _ ( 968 ) ;
/* harmony import */ var next _head _ _WEBPACK _IMPORTED _MODULE _2 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( next _head _ _WEBPACK _IMPORTED _MODULE _2 _ _ ) ;
/* harmony import */ var _functions _backend _userAuth _ _WEBPACK _IMPORTED _MODULE _3 _ _ = _ _webpack _require _ _ ( 370 ) ;
/* harmony import */ var _functions _backend _userAuth _ _WEBPACK _IMPORTED _MODULE _3 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _functions _backend _userAuth _ _WEBPACK _IMPORTED _MODULE _3 _ _ ) ;
/* harmony import */ var _components _general _LoadingBlock _ _WEBPACK _IMPORTED _MODULE _4 _ _ = _ _webpack _require _ _ ( 5264 ) ;
/* harmony import */ var _functions _frontend _fetchApi _ _WEBPACK _IMPORTED _MODULE _9 _ _ = _ _webpack _require _ _ ( 6729 ) ;
/* harmony import */ var _package _shared _functions _backend _decrypt _ _WEBPACK _IMPORTED _MODULE _5 _ _ = _ _webpack _require _ _ ( 5304 ) ;
/* harmony import */ var _package _shared _functions _backend _decrypt _ _WEBPACK _IMPORTED _MODULE _5 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _package _shared _functions _backend _decrypt _ _WEBPACK _IMPORTED _MODULE _5 _ _ ) ;
/* harmony import */ var _layouts _GeneralLayout _ _WEBPACK _IMPORTED _MODULE _6 _ _ = _ _webpack _require _ _ ( 6217 ) ;
/* harmony import */ var _functions _backend _serverError _ _WEBPACK _IMPORTED _MODULE _7 _ _ = _ _webpack _require _ _ ( 2317 ) ;
/* harmony import */ var _functions _backend _serverError _ _WEBPACK _IMPORTED _MODULE _7 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _functions _backend _serverError _ _WEBPACK _IMPORTED _MODULE _7 _ _ ) ;
/* harmony import */ var _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _8 _ _ = _ _webpack _require _ _ ( 9395 ) ;
/* harmony import */ var _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _8 _ _ _default = /*#__PURE__*/ _ _webpack _require _ _ . n ( _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _8 _ _ ) ;
// @ts-check
/ * *
* Imports
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* /
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* Main Component { Functional }
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ param { Object } props - React component props including { children }
* @ param { import ( "@/package-shared/types" ) . UserType } props . user
* @ param { boolean } props . verified
* / f u n c t i o n V e r i f y E m a i l ( { u s e r , v e r i f i e d } ) {
/ * *
* Get Contexts
*
* @ abstract { React . useContext }
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Javascript Variables
*
* @ abstract Non hook variables and functions
* / / ///////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* React Hooks
*
* @ abstract { useState , useEffect , useRef , etc ... }
* / c o n s t [ l o a d i n g , s e t L o a d i n g ] = r e a c t _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 1 _ _ _ d e f a u l t ( ) . u s e S t a t e ( f a l s e ) ;
/** @type {[ state: any, dispatch: React.Dispatch<React.SetStateAction<any>> ]} */ // @ts-ignore
let [ notification , setNotification ] = react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . useState ( null ) ;
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ if ( verified ) {
react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . useEffect ( ( ) => {
try {
setTimeout ( ( ) => {
window . location . pathname = ` /admin ` ;
} , 2000 ) ;
} catch ( /** @type {any} */ error ) {
( 0 , _functions _frontend _fetchApi _ _WEBPACK _IMPORTED _MODULE _9 _ _ /* ["default"] */ . Z ) ( "/api/admin/clientError" , {
method : "post" ,
body : {
component : "email-verification/index-page-component/lines-72-74" ,
message : error . message ,
user : user
}
} ) ;
window . location . pathname = ` /logout ` ;
}
} , [ ] ) ;
return /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _layouts _GeneralLayout _ _WEBPACK _IMPORTED _MODULE _6 _ _ /* ["default"] */ . Z , {
head : /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( ( react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . Fragment ) , {
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "title" , {
children : "Verify Email Address"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "meta" , {
name : "description" ,
content : "Verify your email address"
} )
]
} ) ,
user : user ,
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "main" , {
className : "flex items-center justify-center w-full p-8" ,
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "div" , {
className : "login-block gap-2" ,
children : /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "flex items-center gap-4" ,
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "img" , {
src : "/images/checkmark.svg" ,
alt : "check-mark" ,
width : 30
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
className : "text-xl" ,
children : "Email Verification Successfull!"
} )
]
} )
} )
} )
} ) ;
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ function verifyEmail ( /** @type {any} */ e ) {
e . preventDefault ( ) ;
setLoading ( true ) ;
( 0 , _functions _frontend _fetchApi _ _WEBPACK _IMPORTED _MODULE _9 _ _ /* ["default"] */ . Z ) ( "/api/sendEmailVerificationLink" ) . then ( ( res ) => {
setLoading ( false ) ;
if ( res . success ) {
setNotification ( {
msg : "Email Sent. Please check mailbox" ,
class : "bg-emerald-100"
} ) ;
}
} ) ;
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* Function Return
*
* @ abstract Main Function Return
* / return / * # _ _PURE _ _ * / r e a c t _ j s x _ r u n t i m e _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 0 _ _ . j s x ( ( r e a c t _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 1 _ _ _ d e f a u l t ( ) . F r a g m e n t ) , {
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _layouts _GeneralLayout _ _WEBPACK _IMPORTED _MODULE _6 _ _ /* ["default"] */ . Z , {
head : /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( ( react _ _WEBPACK _IMPORTED _MODULE _1 _ _ _default ( ) . Fragment ) , {
children : [
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "title" , {
children : "Verify Email Address"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "meta" , {
name : "description" ,
content : "Verify your email address"
} )
]
} ) ,
user : user ,
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "main" , {
className : "flex flex-col items-center p-8 justify-center w-full" ,
children : /*#__PURE__*/ ( 0 , react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsxs ) ( "div" , {
className : "login-block gap-2 flex-col max-w-lg" ,
children : [
notification && /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "div" , {
className : notification . class + " w-full rounded py-2 px-4 flex justify-center" ,
children : notification . msg
} ) ,
loading && /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( _components _general _LoadingBlock _ _WEBPACK _IMPORTED _MODULE _4 _ _ /* ["default"] */ . Z , {
position : "absolute"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "h1" , {
className : "text-2xl m-0 " ,
children : "Verify Email Address"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
children : "Please click the button below to send verification link"
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "button" , {
className : "w-full" ,
onClick : verifyEmail ,
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
children : "Send Verification Link"
} )
} ) ,
/*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "button" , {
className : "w-full outlined" ,
onClick : ( e ) => {
window . history . back ( ) ;
} ,
children : /*#__PURE__*/ react _jsx _runtime _ _WEBPACK _IMPORTED _MODULE _0 _ _ . jsx ( "span" , {
children : "Go Back"
} )
} )
]
} )
} )
} )
} ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ /** ****************************************************************************** */ / * *
* Server Side Props or Static Props
* === === === === === === === === === === === === === === === === === === === === === === === === === ===
* @ type { import ( "next" ) . GetServerSideProps }
* / a s y n c f u n c t i o n g e t S e r v e r S i d e P r o p s ( { r e q , r e s , q u e r y } ) {
/ * *
* Declare core variables
*
* @ description Declare core variables
* / l e t u s e r ;
let isUserVerified = false ;
try {
/ * *
* User Authentication
*
* @ description User authentication
* / u s e r = a w a i t _ f u n c t i o n s _ b a c k e n d _ u s e r A u t h _ _ W E B P A C K _ I M P O R T E D _ M O D U L E _ 3 _ _ _ d e f a u l t ( ) ( r e q , r e s ) ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Page / Site Data Data Fetching
*
* @ description Fetch data on the server before returning
* / / * * @ type { string | null } * / / / @ ts - ignore
let token = query ? . token ;
if ( token ) {
let decryptedToken = _package _shared _functions _backend _decrypt _ _WEBPACK _IMPORTED _MODULE _5 _ _ _default ( ) ( token . toString ( ) ) ;
if ( decryptedToken ) {
try {
user = JSON . parse ( decryptedToken ) ;
} catch ( /** @type {any} */ error ) {
_functions _backend _serverError _ _WEBPACK _IMPORTED _MODULE _7 _ _ _default ( ) ( {
component : "email-verification/index-page-component/getServerSideProps/line-255" ,
message : error . message ,
user : { }
} ) ;
user = null ;
token = null ;
}
}
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if ( ! user ) return {
redirect : {
destination : "/logout" ,
permanent : false
}
} ;
if ( user . verification _status ? . toString ( ) . match ( /^[1-5]$/ ) ) return {
redirect : {
destination : ` /admin ` ,
permanent : false
}
} ;
let existingVerification = await _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _8 _ _ _default ( ) ( ` SELECT id FROM users WHERE verification_status > 0 AND id=' ${ user . id } ' ` ) ;
if ( existingVerification && existingVerification [ 0 ] ) return {
redirect : {
destination : ` /admin ` ,
permanent : false
}
} ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
if ( user ? . dateCode ) {
let issueTime = user . dateCode ;
if ( Date . now ( ) - parseInt ( issueTime ) > 1800000 ) {
user = null ;
token = null ;
} else {
await _package _shared _utils _backend _global _db _DB _HANDLER _ _WEBPACK _IMPORTED _MODULE _8 _ _ _default ( ) ( ` UPDATE users SET verification_status='1' WHERE id=' ${ user . id } ' ` ) ;
isUserVerified = true ;
}
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
} catch ( /** @type {any} */ error1 ) {
_functions _backend _serverError _ _WEBPACK _IMPORTED _MODULE _7 _ _ _default ( ) ( {
component : "email-verification/index-page-component/getServerSideProps/main-catch-error" ,
message : error1 . message ,
user : { }
} ) ;
return {
redirect : {
destination : "/logout" ,
permanent : false
}
} ;
}
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
/ * *
* Server props return
*
* @ description Return data fetched on the server side
* / r e t u r n {
props : {
user : user ,
verified : isUserVerified
}
} ;
////////////////////////////////////////
////////////////////////////////////////
////////////////////////////////////////
}
/***/ } ) ,
/***/ 386 :
/***/ ( ( module ) => {
module . exports = require ( "@mui/icons-material/CottageTwoTone" ) ;
/***/ } ) ,
/***/ 5557 :
/***/ ( ( module ) => {
module . exports = require ( "@mui/icons-material/MenuBookTwoTone" ) ;
/***/ } ) ,
/***/ 2423 :
/***/ ( ( module ) => {
module . exports = require ( "lucide-react" ) ;
/***/ } ) ,
/***/ 968 :
/***/ ( ( module ) => {
module . exports = require ( "next/head" ) ;
/***/ } ) ,
/***/ 6689 :
/***/ ( ( module ) => {
module . exports = require ( "react" ) ;
/***/ } ) ,
/***/ 997 :
/***/ ( ( module ) => {
module . exports = require ( "react/jsx-runtime" ) ;
/***/ } ) ,
/***/ 2261 :
/***/ ( ( module ) => {
module . exports = require ( "serverless-mysql" ) ;
/***/ } ) ,
/***/ 4300 :
/***/ ( ( module ) => {
module . exports = require ( "buffer" ) ;
/***/ } ) ,
/***/ 6113 :
/***/ ( ( module ) => {
module . exports = require ( "crypto" ) ;
/***/ } ) ,
/***/ 7147 :
/***/ ( ( module ) => {
module . exports = require ( "fs" ) ;
/***/ } ) ,
/***/ 3685 :
/***/ ( ( module ) => {
module . exports = require ( "http" ) ;
/***/ } ) ,
/***/ 1017 :
/***/ ( ( module ) => {
module . exports = require ( "path" ) ;
/***/ } )
} ;
;
// load runtime
var _ _webpack _require _ _ = require ( "../webpack-runtime.js" ) ;
_ _webpack _require _ _ . C ( exports ) ;
var _ _webpack _exec _ _ = ( moduleId ) => ( _ _webpack _require _ _ ( _ _webpack _require _ _ . s = moduleId ) )
2024-11-05 14:18:40 +00:00
var _ _webpack _exports _ _ = _ _webpack _require _ _ . X ( 0 , [ 4017 , 8313 , 5264 , 6729 , 5449 , 913 , 4480 , 370 , 9360 , 6217 , 2317 ] , ( ) => ( _ _webpack _exec _ _ ( 5004 ) ) ) ;
2024-11-05 11:12:42 +00:00
module . exports = _ _webpack _exports _ _ ;
} ) ( ) ;