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,IAAI,iBAAiBzF,UAAU,YACpD,GAAA8D,EAAA3D,GAAA,EAACuF,KAAAA,CAAG1F,UAAU,gCAAuB,2BACrC,GAAA8D,EAAA3D,GAAA,EAACC,MAAAA,CAAIJ,UAAU,mCAA0B,gCAI3C,GAAA8D,EAAAC,IAAA,EAACnE,EAAAA,EAAIA,CAAAA,CAACI,UAAU,6FACd,GAAA8D,EAAA3D,GAAA,EAACC,MAAAA,UAAKjC,IACN,GAAA2F,EAAA3D,GAAA,EAAC4B,UAASA,CAACC,YAAa7D,OAE1B,GAAA2F,EAAAC,IAAA,EAAC3D,MAAAA,CAAIJ,UAAU,+CAAqC,yBAC3B,IACvB,GAAA8D,EAAA3D,GAAA,EAACsE,IAAIA,CAAC9E,KAAM,oBAAsCpC,MAAA,CAAlBwH,EAAOY,QAAQ,IAAM3F,UAAU,gBAAO,oBAOhF","sources":["webpack://_N_E/?f1d5","webpack://_N_E/./components/auth/api.ts","webpack://_N_E/./components/ui/card.tsx","webpack://_N_E/./packages/dayjs/index.ts","webpack://_N_E/./components/auth/login-form.tsx","webpack://_N_E/./pages/login.tsx","webpack://_N_E/"],"sourcesContent":["\n (window.__NEXT_P = window.__NEXT_P || []).push([\n \"/login\",\n function () {\n return require(\"private-next-pages/login.tsx\");\n }\n ]);\n if(module.hot) {\n module.hot.dispose(function () {\n window.__NEXT_P.push([\"/login\"])\n });\n }\n ","import { API_URL, superFetch } from \"@/lib/utils\";\nimport { clearStorage } from \"@/stores/auth-store\";\n\nimport { RegisterRequest } from \"./interface\";\n\ninterface LoginData {\n email: string;\n password: string;\n}\n\nexport async function fetchLogin(data: LoginData) {\n const res = await fetch(`${API_URL}/users/login`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(data),\n });\n return res.json();\n}\n\nexport async function fetchRegisterUser(data: RegisterRequest) {\n const res = await fetch(`${API_URL}/users/register`, {\n method: \"POST\",\n headers: {\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify(data),\n });\n const json = await res.json();\n if (!res.ok) {\n throw new Error(json.message || \"An error occurred\");\n }\n return true;\n}\n\nexport const fetchAcceptInvite = async (invite_token: string) => {\n const url = `${API_URL}/users/accept_invite`;\n const body = JSON.stringify({ invite_token });\n\n return await superFetch(url, { method: \"POST\", body });\n};\n\nexport async function sendVerifyEmail(email: string) {\n const res = await fetch(`${API_URL}/users/resend-verify-email`, {\n method: \"POST\",\n body: JSON.stringify({ email }),\n });\n return res.json();\n}\n\nexport async function fetchUniversityList(url: string) {\n const res = await fetch(`${API_URL}${url}`);\n const json = await res.json();\n return json.data;\n}\n\nexport async function sendResetPasswordEmail(email: string) {\n const res = await fetch(`${API_URL}/users/reset-password`, {\n method: \"POST\",\n body: JSON.stringify({ email }),\n });\n return res;\n}\n\nexport async function updatePassword(data: any) {\n const res = await fetch(`${API_URL}/users/update-password`, {\n method: \"POST\",\n body: JSON.stringify(data),\n });\n return res;\n}\n\nexport async function refreshToken() {\n const refresh_token = localStorage.getItem(\"refreshToken\");\n if (!refresh_token) {\n throw new Error(\n \"[No refresh_token] Some error occurred. Please try again.\",\n );\n }\n\n return superFetch(`${API_URL}/users/refresh`, {\n method: \"POST\",\n body: JSON.stringify({ refresh_token }),\n }) as any;\n}\n\nexport async function getRefreshToken(triggerRefreshRef: any) {\n try {\n if (triggerRefreshRef.current) {\n return;\n }\n triggerRefreshRef.current = true;\n const res = await refreshToken();\n const user = res?.data;\n if (!user) {\n throw new Error(\"Invalid refresh data\");\n }\n localStorage.setItem(\"user\", JSON.stringify(user));\n localStorage.setItem(\"authToken\", user.token);\n window.location.reload();\n } catch (err) {\n clearStorage();\n const path = window.location.pathname;\n window.location.href = \"/login?redirect=\" + path;\n }\n}\n","import * as React from \"react\";\n\nimport { cn } from \"@/lib/utils\";\n\nconst Card = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes\n>(({ className, ...props }, ref) => (\n \n));\nCard.displayName = \"Card\";\n\nconst CardHeader = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes\n>(({ className, ...props }, ref) => (\n \n));\nCardHeader.displayName = \"CardHeader\";\n\nconst CardTitle = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes\n>(({ className, ...props }, ref) => (\n \n));\nCardTitle.displayName = \"CardTitle\";\n\nconst CardDescription = React.forwardRef<\n HTMLParagraphElement,\n React.HTMLAttributes\n>(({ className, ...props }, ref) => (\n \n));\nCardDescription.displayName = \"CardDescription\";\n\nconst CardContent = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes\n>(({ className, ...props }, ref) => (\n
\n));\nCardContent.displayName = \"CardContent\";\n\nconst CardFooter = React.forwardRef<\n HTMLDivElement,\n React.HTMLAttributes\n>(({ className, ...props }, ref) => (\n \n));\nCardFooter.displayName = \"CardFooter\";\n\nexport {\n Card,\n CardContent,\n CardDescription,\n CardFooter,\n CardHeader,\n CardTitle,\n};\n","import dayjs from \"dayjs\";\nimport customParseFormat from \"dayjs/plugin/customParseFormat\";\nimport duration from \"dayjs/plugin/duration\";\nimport isBetween from \"dayjs/plugin/isBetween\";\nimport isToday from \"dayjs/plugin/isToday\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat\";\nimport minmax from \"dayjs/plugin/minMax\";\nimport relativeTime from \"dayjs/plugin/relativeTime\";\nimport timeZone from \"dayjs/plugin/timezone\";\nimport toArray from \"dayjs/plugin/toArray\";\nimport utc from \"dayjs/plugin/utc\";\n// import dayjsBusinessTime from \"dayjs-business-days2\";\n\ndayjs.extend(customParseFormat);\n// dayjs.extend(dayjsBusinessTime);\ndayjs.extend(isBetween);\ndayjs.extend(isToday);\ndayjs.extend(localizedFormat);\ndayjs.extend(relativeTime);\ndayjs.extend(timeZone);\ndayjs.extend(toArray);\ndayjs.extend(utc);\ndayjs.extend(minmax);\ndayjs.extend(duration);\n\nexport type Dayjs = dayjs.Dayjs;\n\nexport type { ConfigType } from \"dayjs\";\n\nexport default dayjs;\n","import { zodResolver } from \"@hookform/resolvers/zod\";\nimport Link from \"next/link\";\nimport { useRouter } from \"next/router\";\nimport { useState } from \"react\";\nimport { useForm } from \"react-hook-form\";\nimport * as z from \"zod\";\n\nimport { Button } from \"@/components/ui/button\";\nimport { Form, FormItemField } from \"@/components/ui/form\";\nimport useAuthStore from \"@/stores/auth-store\";\n\nimport { toast } from \"../ui/use-toast\";\nimport { fetchAcceptInvite, fetchLogin, sendVerifyEmail } from \"./api\";\n\nconst formSchema = z.object({\n email: z\n .string()\n .email(\"Please enter your work email address.\")\n .min(1, \"Please enter your work email address.\"),\n password: z.string().min(10, {\n message: \"Please enter your password\",\n }),\n});\n\nexport function LoginForm({ inviteToken }: { inviteToken: string }) {\n const router = useRouter();\n const [error, setError] = useState(null);\n const { setUser } = useAuthStore();\n const form = useForm>({\n resolver: zodResolver(formSchema),\n defaultValues: {\n email: \"\",\n password: \"\",\n },\n });\n const [busy, setBusy] = useState(false);\n\n async function onSubmit(values: z.infer) {\n try {\n const redirect = router.query.redirect as string | undefined;\n setError(null);\n setBusy(true);\n const res = await fetchLogin(values);\n // check if email is verified\n if (res.code === \"EMAIL_NOT_VERIFIED\") {\n await sendVerifyEmail(values.email);\n router.push(`/signup/verify-request?email=${values.email}`);\n return;\n }\n\n if (res.data?.user) {\n const {\n data: { user },\n } = res;\n setUser(user);\n if (inviteToken) {\n fetchAcceptInvite(String(inviteToken))\n .then((invite) => {\n toast({ title: \"Invitation to organization accepted\" });\n })\n .catch((err) => {\n toast({ title: err.message });\n })\n .finally(() => router.push(\"/home\"));\n }\n\n if (user.user_type === \"university\") {\n if (!user.org?.id) {\n router.push(\"/organization-setup/intro\");\n } else {\n router.push(redirect || \"/hosting/dashboard\");\n }\n return;\n } else {\n // researcher already associated with an org or skip setup org\n if (user.skip_setup_org || user.org?.id) {\n if (user.user_type === \"uni_office\") {\n router.push(redirect || \"/home\");\n return;\n }\n router.push(redirect || \"/home\");\n } else {\n router.push(\n `/company-setup/intro?${redirect ? `redirect=${redirect}` : \"\"}`,\n );\n }\n }\n } else {\n throw new Error(res.message);\n }\n } catch (err: any) {\n setError(err.message);\n } finally {\n setBusy(false);\n }\n }\n\n return (\n
\n {!!error && (\n
{error}
\n )}\n \n \n \n
\n \n Forgot Password?\n \n
\n
\n \n
\n \n \n );\n}\n","import { NextPageContext } from \"next\";\nimport Head from \"next/head\";\nimport Link from \"next/link\";\n\nimport { LoginForm } from \"@/components/auth/login-form\";\nimport { Card } from \"@/components/ui/card\";\nimport { redirectToHome } from \"@/lib/utils\";\nimport useAuthStore from \"@/stores/auth-store\";\n\nexport const getServerSideProps = async (context: NextPageContext) => {\n const { invite_token, redirect, referrer_org_id, referrer_source } =\n context.query;\n\n return {\n props: {\n invite_token: invite_token ? String(invite_token) : \"\",\n redirect: redirect ? String(redirect) : \"\",\n referrerOrgId: referrer_org_id ? Number(referrer_org_id) : 0,\n referrerSource: referrer_source ? String(referrer_source) : \"\",\n },\n };\n};\n\ninterface Props {\n invite_token: string;\n redirect: string;\n referrerOrgId: string;\n referrerSource: string;\n}\n\nexport default function LoginPage({\n invite_token,\n redirect,\n referrerOrgId,\n referrerSource,\n}: Props) {\n const { user, ready } = useAuthStore();\n const params = (() => {\n const params = new URLSearchParams();\n\n if (referrerOrgId) {\n params.append(\"referrer_org_id\", referrerOrgId);\n }\n if (referrerSource) {\n params.append(\"referrer_source\", referrerSource);\n }\n if (redirect) {\n params.append(\"redirect\", redirect);\n }\n return params;\n })();\n\n if (!ready) {\n return <>;\n }\n\n if (redirectToHome(user)) {\n return <>;\n }\n\n return (\n <>\n \n Sign In | Second Lab\n \n \n
\n
\n \"secondlab-logo\"\n

Welcome to Second Lab!

\n
\n Sign in to your account.\n
\n
\n \n
{invite_token}
\n \n
\n
\n Don’t have an account?{\" \"}\n \n Sign Up\n \n
\n
\n \n );\n}\n"],"names":["window","__NEXT_P","push","__webpack_require__","fetchLogin","data","res","fetch","concat","API_URL","method","headers","body","JSON","stringify","json","fetchRegisterUser","ok","message","fetchAcceptInvite","invite_token","url","superFetch","sendVerifyEmail","email","fetchUniversityList","sendResetPasswordEmail","updatePassword","refreshToken","refresh_token","localStorage","getItem","getRefreshToken","triggerRefreshRef","current","user","setItem","token","location","reload","err","clearStorage","path","pathname","href","Card","React","param","ref","className","props","react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__","jsx","div","cn","displayName","CardHeader","CardTitle","h3","CardDescription","p","CardContent","CardFooter","dayjs","customParseFormat","isBetween","isToday","localizedFormat","relativeTime","timeZone","toArray","utc","minmax","duration","__webpack_exports__","Z","formSchema","z","min","password","LoginForm","inviteToken","router","useRouter","error","setError","useState","setUser","useAuthStore","form","useForm","resolver","zodResolver","defaultValues","busy","setBusy","onSubmit","values","redirect","query","code","String","then","toast","title","catch","finally","user_type","org","id","skip_setup_org","jsx_runtime","jsxs","Form","handleSubmit","FormItemField","label","control","name","placeholder","inputProps","type","Link","Button","LoginPage","referrerOrgId","referrerSource","ready","params","URLSearchParams","append","redirectToHome","Fragment","Head","meta","content","img","src","alt","h2","toString"],"sourceRoot":""}