2021-09-13 09:48:55 +00:00
|
|
|
import { GetServerSidePropsContext } from "next";
|
|
|
|
import { RefObject, useEffect, useRef, useState } from "react";
|
2021-08-22 13:16:42 +00:00
|
|
|
import prisma from "@lib/prisma";
|
2021-08-27 12:35:20 +00:00
|
|
|
import Modal from "@components/Modal";
|
|
|
|
import Shell from "@components/Shell";
|
|
|
|
import SettingsShell from "@components/Settings";
|
2021-08-22 13:16:42 +00:00
|
|
|
import Avatar from "@components/Avatar";
|
2021-09-03 20:51:21 +00:00
|
|
|
import { getSession } from "@lib/auth";
|
2021-07-09 22:59:21 +00:00
|
|
|
import Select from "react-select";
|
2021-06-23 15:49:10 +00:00
|
|
|
import TimezoneSelect from "react-timezone-select";
|
2021-08-27 12:35:20 +00:00
|
|
|
import { UsernameInput } from "@components/ui/UsernameInput";
|
|
|
|
import ErrorAlert from "@components/ui/alerts/Error";
|
|
|
|
import ImageUploader from "@components/ImageUploader";
|
2021-08-22 13:16:42 +00:00
|
|
|
import crypto from "crypto";
|
2021-09-13 09:48:55 +00:00
|
|
|
import { inferSSRProps } from "@lib/types/inferSSRProps";
|
|
|
|
import Badge from "@components/ui/Badge";
|
|
|
|
import Button from "@components/ui/Button";
|
|
|
|
import { isBrandingHidden } from "@lib/isBrandingHidden";
|
2021-04-07 15:03:02 +00:00
|
|
|
|
2021-07-22 12:16:21 +00:00
|
|
|
const themeOptions = [
|
|
|
|
{ value: "light", label: "Light" },
|
|
|
|
{ value: "dark", label: "Dark" },
|
|
|
|
];
|
|
|
|
|
2021-09-13 09:48:55 +00:00
|
|
|
type Props = inferSSRProps<typeof getServerSideProps>;
|
|
|
|
function HideBrandingInput(props: {
|
|
|
|
//
|
|
|
|
hideBrandingRef: RefObject<HTMLInputElement>;
|
|
|
|
user: Props["user"];
|
|
|
|
}) {
|
|
|
|
const [modelOpen, setModalOpen] = useState(false);
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<input
|
|
|
|
id="hide-branding"
|
|
|
|
name="hide-branding"
|
|
|
|
type="checkbox"
|
|
|
|
ref={props.hideBrandingRef}
|
|
|
|
defaultChecked={isBrandingHidden(props.user)}
|
|
|
|
className={
|
|
|
|
"focus:ring-neutral-500 h-4 w-4 text-neutral-900 border-gray-300 rounded-sm disabled:opacity-50"
|
|
|
|
}
|
|
|
|
onClick={(e) => {
|
|
|
|
if (!e.currentTarget.checked || props.user.plan !== "FREE") {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// prevent checking the input
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
setModalOpen(true);
|
|
|
|
}}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<Modal
|
|
|
|
heading="This feature is only available in paid plan"
|
|
|
|
variant="warning"
|
|
|
|
description={
|
|
|
|
<div className="flex flex-col space-y-3">
|
|
|
|
<p>
|
|
|
|
In order to remove the Calendso branding from your booking pages, you need to upgrade to a paid
|
|
|
|
account.
|
|
|
|
</p>
|
|
|
|
|
|
|
|
<p>
|
|
|
|
{" "}
|
|
|
|
To upgrade go to{" "}
|
|
|
|
<a href="https://calendso.com/upgrade" className="underline">
|
|
|
|
calendso.com/upgrade
|
|
|
|
</a>
|
|
|
|
.
|
|
|
|
</p>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
open={modelOpen}
|
|
|
|
handleClose={() => setModalOpen(false)}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default function Settings(props: Props) {
|
2021-06-23 15:49:10 +00:00
|
|
|
const [successModalOpen, setSuccessModalOpen] = useState(false);
|
2021-09-13 09:48:55 +00:00
|
|
|
const usernameRef = useRef<HTMLInputElement>(null);
|
|
|
|
const nameRef = useRef<HTMLInputElement>(null);
|
2021-06-23 15:49:10 +00:00
|
|
|
const descriptionRef = useRef<HTMLTextAreaElement>();
|
2021-09-13 09:48:55 +00:00
|
|
|
const avatarRef = useRef<HTMLInputElement>(null);
|
|
|
|
const hideBrandingRef = useRef<HTMLInputElement>(null);
|
2021-07-22 12:16:21 +00:00
|
|
|
const [selectedTheme, setSelectedTheme] = useState({ value: props.user.theme });
|
2021-06-23 15:49:10 +00:00
|
|
|
const [selectedTimeZone, setSelectedTimeZone] = useState({ value: props.user.timeZone });
|
2021-07-22 12:16:21 +00:00
|
|
|
const [selectedWeekStartDay, setSelectedWeekStartDay] = useState({ value: props.user.weekStart });
|
2021-08-22 13:16:42 +00:00
|
|
|
const [imageSrc, setImageSrc] = useState<string>(props.user.avatar);
|
2021-04-07 15:03:02 +00:00
|
|
|
|
2021-06-23 15:49:10 +00:00
|
|
|
const [hasErrors, setHasErrors] = useState(false);
|
|
|
|
const [errorMessage, setErrorMessage] = useState("");
|
2021-04-20 12:56:50 +00:00
|
|
|
|
2021-07-11 19:35:56 +00:00
|
|
|
useEffect(() => {
|
|
|
|
setSelectedTheme(
|
|
|
|
props.user.theme ? themeOptions.find((theme) => theme.value === props.user.theme) : null
|
|
|
|
);
|
2021-07-09 22:59:21 +00:00
|
|
|
setSelectedWeekStartDay({ value: props.user.weekStart, label: props.user.weekStart });
|
|
|
|
}, []);
|
|
|
|
|
2021-06-23 15:49:10 +00:00
|
|
|
const closeSuccessModal = () => {
|
|
|
|
setSuccessModalOpen(false);
|
|
|
|
};
|
2021-06-09 12:26:00 +00:00
|
|
|
|
2021-08-12 04:44:11 +00:00
|
|
|
const handleAvatarChange = (newAvatar) => {
|
|
|
|
avatarRef.current.value = newAvatar;
|
2021-08-19 12:27:01 +00:00
|
|
|
const nativeInputValueSetter = Object.getOwnPropertyDescriptor(
|
|
|
|
window.HTMLInputElement.prototype,
|
|
|
|
"value"
|
|
|
|
).set;
|
|
|
|
nativeInputValueSetter.call(avatarRef.current, newAvatar);
|
|
|
|
const ev2 = new Event("input", { bubbles: true });
|
2021-08-12 04:44:11 +00:00
|
|
|
avatarRef.current.dispatchEvent(ev2);
|
|
|
|
updateProfileHandler(ev2);
|
2021-08-19 12:27:01 +00:00
|
|
|
setImageSrc(newAvatar);
|
|
|
|
};
|
2021-08-12 04:44:11 +00:00
|
|
|
|
2021-06-23 15:49:10 +00:00
|
|
|
const handleError = async (resp) => {
|
|
|
|
if (!resp.ok) {
|
|
|
|
const error = await resp.json();
|
|
|
|
throw new Error(error.message);
|
2021-04-07 15:03:02 +00:00
|
|
|
}
|
2021-06-23 15:49:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
async function updateProfileHandler(event) {
|
|
|
|
event.preventDefault();
|
|
|
|
|
|
|
|
const enteredUsername = usernameRef.current.value.toLowerCase();
|
|
|
|
const enteredName = nameRef.current.value;
|
|
|
|
const enteredDescription = descriptionRef.current.value;
|
|
|
|
const enteredAvatar = avatarRef.current.value;
|
|
|
|
const enteredTimeZone = selectedTimeZone.value;
|
2021-07-09 22:59:21 +00:00
|
|
|
const enteredWeekStartDay = selectedWeekStartDay.value;
|
2021-06-29 16:08:55 +00:00
|
|
|
const enteredHideBranding = hideBrandingRef.current.checked;
|
2021-06-23 15:49:10 +00:00
|
|
|
|
|
|
|
// TODO: Add validation
|
|
|
|
|
|
|
|
await fetch("/api/user/profile", {
|
|
|
|
method: "PATCH",
|
|
|
|
body: JSON.stringify({
|
|
|
|
username: enteredUsername,
|
|
|
|
name: enteredName,
|
|
|
|
description: enteredDescription,
|
|
|
|
avatar: enteredAvatar,
|
|
|
|
timeZone: enteredTimeZone,
|
|
|
|
weekStart: enteredWeekStartDay,
|
2021-06-29 16:08:55 +00:00
|
|
|
hideBranding: enteredHideBranding,
|
2021-07-09 22:59:21 +00:00
|
|
|
theme: selectedTheme ? selectedTheme.value : null,
|
2021-06-23 15:49:10 +00:00
|
|
|
}),
|
|
|
|
headers: {
|
|
|
|
"Content-Type": "application/json",
|
|
|
|
},
|
|
|
|
})
|
|
|
|
.then(handleError)
|
|
|
|
.then(() => {
|
|
|
|
setSuccessModalOpen(true);
|
|
|
|
setHasErrors(false); // dismiss any open errors
|
|
|
|
})
|
|
|
|
.catch((err) => {
|
|
|
|
setHasErrors(true);
|
|
|
|
setErrorMessage(err.message);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2021-08-02 14:10:24 +00:00
|
|
|
<Shell heading="Profile" subtitle="Edit your profile information, which shows on your scheduling link.">
|
2021-06-23 15:49:10 +00:00
|
|
|
<SettingsShell>
|
|
|
|
<form className="divide-y divide-gray-200 lg:col-span-9" onSubmit={updateProfileHandler}>
|
|
|
|
{hasErrors && <ErrorAlert message={errorMessage} />}
|
2021-07-30 23:05:38 +00:00
|
|
|
<div className="py-6 lg:pb-8">
|
|
|
|
<div className="flex flex-col lg:flex-row">
|
2021-06-23 15:49:10 +00:00
|
|
|
<div className="flex-grow space-y-6">
|
2021-08-02 17:22:35 +00:00
|
|
|
<div className="block sm:flex">
|
|
|
|
<div className="w-full sm:w-1/2 sm:mr-2 mb-6">
|
2021-06-23 15:49:10 +00:00
|
|
|
<UsernameInput ref={usernameRef} defaultValue={props.user.username} />
|
|
|
|
</div>
|
2021-08-02 17:22:35 +00:00
|
|
|
<div className="w-full sm:w-1/2 sm:ml-2">
|
2021-06-23 15:49:10 +00:00
|
|
|
<label htmlFor="name" className="block text-sm font-medium text-gray-700">
|
|
|
|
Full name
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
ref={nameRef}
|
|
|
|
type="text"
|
|
|
|
name="name"
|
|
|
|
id="name"
|
|
|
|
autoComplete="given-name"
|
|
|
|
placeholder="Your name"
|
|
|
|
required
|
2021-07-30 23:05:38 +00:00
|
|
|
className="mt-1 block w-full border border-gray-300 rounded-sm shadow-sm py-2 px-3 focus:outline-none focus:ring-neutral-500 focus:border-neutral-500 sm:text-sm"
|
2021-06-23 15:49:10 +00:00
|
|
|
defaultValue={props.user.name}
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-04-07 15:03:02 +00:00
|
|
|
|
2021-06-23 15:49:10 +00:00
|
|
|
<div>
|
|
|
|
<label htmlFor="about" className="block text-sm font-medium text-gray-700">
|
|
|
|
About
|
|
|
|
</label>
|
|
|
|
<div className="mt-1">
|
|
|
|
<textarea
|
|
|
|
ref={descriptionRef}
|
|
|
|
id="about"
|
|
|
|
name="about"
|
|
|
|
placeholder="A little something about yourself."
|
|
|
|
rows={3}
|
2021-07-09 22:59:21 +00:00
|
|
|
defaultValue={props.user.bio}
|
2021-07-30 23:05:38 +00:00
|
|
|
className="shadow-sm focus:ring-neutral-500 focus:border-neutral-500 mt-1 block w-full sm:text-sm border-gray-300 rounded-sm"></textarea>
|
2021-06-23 15:49:10 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-08-12 04:44:11 +00:00
|
|
|
<div>
|
|
|
|
<div className="mt-1 flex">
|
2021-08-19 12:27:01 +00:00
|
|
|
<Avatar
|
2021-08-22 13:16:42 +00:00
|
|
|
displayName={props.user.name}
|
2021-08-19 12:27:01 +00:00
|
|
|
className="relative rounded-full w-10 h-10"
|
2021-08-22 13:16:42 +00:00
|
|
|
gravatarFallbackMd5={props.user.emailMd5}
|
2021-08-19 12:27:01 +00:00
|
|
|
imageSrc={imageSrc}
|
|
|
|
/>
|
|
|
|
<input
|
|
|
|
ref={avatarRef}
|
|
|
|
type="hidden"
|
|
|
|
name="avatar"
|
|
|
|
id="avatar"
|
|
|
|
placeholder="URL"
|
|
|
|
className="mt-1 block w-full border border-gray-300 rounded-sm shadow-sm py-2 px-3 focus:outline-none focus:ring-neutral-500 focus:border-neutral-500 sm:text-sm"
|
2021-08-22 13:16:42 +00:00
|
|
|
defaultValue={imageSrc}
|
2021-08-19 12:27:01 +00:00
|
|
|
/>
|
|
|
|
<ImageUploader
|
|
|
|
target="avatar"
|
|
|
|
id="avatar-upload"
|
|
|
|
buttonMsg="Change avatar"
|
|
|
|
handleAvatarChange={handleAvatarChange}
|
2021-08-22 13:16:42 +00:00
|
|
|
imageRef={imageSrc}
|
2021-08-19 12:27:01 +00:00
|
|
|
/>
|
2021-08-12 04:44:11 +00:00
|
|
|
</div>
|
|
|
|
<hr className="mt-6" />
|
2021-08-19 12:27:01 +00:00
|
|
|
</div>
|
2021-06-23 15:49:10 +00:00
|
|
|
<div>
|
|
|
|
<label htmlFor="timeZone" className="block text-sm font-medium text-gray-700">
|
|
|
|
Timezone
|
|
|
|
</label>
|
|
|
|
<div className="mt-1">
|
|
|
|
<TimezoneSelect
|
|
|
|
id="timeZone"
|
|
|
|
value={selectedTimeZone}
|
|
|
|
onChange={setSelectedTimeZone}
|
2021-08-02 15:36:28 +00:00
|
|
|
classNamePrefix="react-select"
|
|
|
|
className="react-select-container border border-gray-300 rounded-sm shadow-sm focus:ring-neutral-500 focus:border-neutral-500 mt-1 block w-full sm:text-sm"
|
2021-06-23 15:49:10 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<label htmlFor="weekStart" className="block text-sm font-medium text-gray-700">
|
|
|
|
First Day of Week
|
|
|
|
</label>
|
|
|
|
<div className="mt-1">
|
2021-07-09 22:59:21 +00:00
|
|
|
<Select
|
2021-06-23 15:49:10 +00:00
|
|
|
id="weekStart"
|
|
|
|
value={selectedWeekStartDay}
|
2021-07-09 22:59:21 +00:00
|
|
|
onChange={setSelectedWeekStartDay}
|
2021-08-02 15:36:28 +00:00
|
|
|
classNamePrefix="react-select"
|
|
|
|
className="react-select-container border border-gray-300 rounded-sm shadow-sm focus:ring-neutral-500 focus:border-neutral-500 mt-1 block w-full sm:text-sm"
|
2021-07-09 22:59:21 +00:00
|
|
|
options={[
|
2021-07-11 19:35:56 +00:00
|
|
|
{ value: "Sunday", label: "Sunday" },
|
|
|
|
{ value: "Monday", label: "Monday" },
|
|
|
|
]}
|
|
|
|
/>
|
2021-07-09 22:59:21 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
<label htmlFor="theme" className="block text-sm font-medium text-gray-700">
|
|
|
|
Single Theme
|
|
|
|
</label>
|
|
|
|
<div className="my-1">
|
|
|
|
<Select
|
|
|
|
id="theme"
|
|
|
|
isDisabled={!selectedTheme}
|
|
|
|
defaultValue={selectedTheme || themeOptions[0]}
|
2021-07-22 12:16:21 +00:00
|
|
|
value={selectedTheme || themeOptions[0]}
|
2021-07-09 22:59:21 +00:00
|
|
|
onChange={setSelectedTheme}
|
2021-07-30 23:05:38 +00:00
|
|
|
className="shadow-sm focus:ring-neutral-500 focus:border-neutral-500 mt-1 block w-full sm:text-sm border-gray-300 rounded-sm"
|
2021-07-11 19:35:56 +00:00
|
|
|
options={themeOptions}
|
|
|
|
/>
|
2021-07-09 22:59:21 +00:00
|
|
|
</div>
|
2021-07-30 23:05:38 +00:00
|
|
|
<div className="mt-8 relative flex items-start">
|
2021-07-09 22:59:21 +00:00
|
|
|
<div className="flex items-center h-5">
|
|
|
|
<input
|
|
|
|
id="theme-adjust-os"
|
|
|
|
name="theme-adjust-os"
|
|
|
|
type="checkbox"
|
|
|
|
onChange={(e) => setSelectedTheme(e.target.checked ? null : themeOptions[0])}
|
|
|
|
defaultChecked={!selectedTheme}
|
2021-07-30 23:05:38 +00:00
|
|
|
className="focus:ring-neutral-500 h-4 w-4 text-neutral-900 border-gray-300 rounded-sm"
|
2021-07-09 22:59:21 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="ml-3 text-sm">
|
|
|
|
<label htmlFor="theme-adjust-os" className="font-medium text-gray-700">
|
|
|
|
Automatically adjust theme based on invitee preferences
|
|
|
|
</label>
|
|
|
|
</div>
|
2021-06-23 15:49:10 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
2021-06-29 16:08:55 +00:00
|
|
|
<div>
|
|
|
|
<div className="relative flex items-start">
|
|
|
|
<div className="flex items-center h-5">
|
2021-09-13 09:48:55 +00:00
|
|
|
<HideBrandingInput user={props.user} hideBrandingRef={hideBrandingRef} />
|
2021-06-29 16:08:55 +00:00
|
|
|
</div>
|
|
|
|
<div className="ml-3 text-sm">
|
|
|
|
<label htmlFor="hide-branding" className="font-medium text-gray-700">
|
2021-09-13 09:48:55 +00:00
|
|
|
Disable Calendso branding{" "}
|
|
|
|
{props.user.plan !== "PRO" && <Badge variant="default">PRO</Badge>}
|
2021-06-29 16:08:55 +00:00
|
|
|
</label>
|
|
|
|
<p className="text-gray-500">Hide all Calendso branding from your public pages.</p>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-06-23 15:49:10 +00:00
|
|
|
</div>
|
|
|
|
|
2021-08-12 04:44:11 +00:00
|
|
|
{/*<div className="mt-6 flex-grow lg:mt-0 lg:ml-6 lg:flex-grow-0 lg:flex-shrink-0">
|
2021-06-23 15:49:10 +00:00
|
|
|
<p className="mb-2 text-sm font-medium text-gray-700" aria-hidden="true">
|
|
|
|
Photo
|
|
|
|
</p>
|
|
|
|
<div className="mt-1 lg:hidden">
|
|
|
|
<div className="flex items-center">
|
|
|
|
<div
|
|
|
|
className="flex-shrink-0 inline-block rounded-full overflow-hidden h-12 w-12"
|
|
|
|
aria-hidden="true">
|
|
|
|
<Avatar user={props.user} className="rounded-full h-full w-full" />
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className="hidden relative rounded-full overflow-hidden lg:block">
|
|
|
|
<Avatar
|
|
|
|
user={props.user}
|
|
|
|
className="relative rounded-full w-40 h-40"
|
2021-07-30 23:05:38 +00:00
|
|
|
fallback={<div className="relative bg-neutral-900 rounded-full w-40 h-40"></div>}
|
2021-06-23 15:49:10 +00:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
<div className="mt-4">
|
|
|
|
<label htmlFor="avatar" className="block text-sm font-medium text-gray-700">
|
|
|
|
Avatar URL
|
|
|
|
</label>
|
|
|
|
<input
|
|
|
|
ref={avatarRef}
|
|
|
|
type="text"
|
|
|
|
name="avatar"
|
|
|
|
id="avatar"
|
|
|
|
placeholder="URL"
|
2021-07-30 23:05:38 +00:00
|
|
|
className="mt-1 block w-full border border-gray-300 rounded-sm shadow-sm py-2 px-3 focus:outline-none focus:ring-neutral-500 focus:border-neutral-500 sm:text-sm"
|
2021-06-23 15:49:10 +00:00
|
|
|
defaultValue={props.user.avatar}
|
|
|
|
/>
|
|
|
|
</div>
|
2021-08-12 04:44:11 +00:00
|
|
|
</div>*/}
|
2021-06-23 15:49:10 +00:00
|
|
|
</div>
|
|
|
|
<hr className="mt-8" />
|
|
|
|
<div className="py-4 flex justify-end">
|
2021-09-13 09:48:55 +00:00
|
|
|
<Button type="submit">Save</Button>
|
2021-06-23 15:49:10 +00:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</form>
|
|
|
|
<Modal
|
|
|
|
heading="Profile updated successfully"
|
|
|
|
description="Your user profile has been updated successfully."
|
|
|
|
open={successModalOpen}
|
|
|
|
handleClose={closeSuccessModal}
|
|
|
|
/>
|
|
|
|
</SettingsShell>
|
|
|
|
</Shell>
|
|
|
|
);
|
2021-04-07 15:03:02 +00:00
|
|
|
}
|
|
|
|
|
2021-09-13 09:48:55 +00:00
|
|
|
export const getServerSideProps = async (context: GetServerSidePropsContext) => {
|
2021-06-23 15:49:10 +00:00
|
|
|
const session = await getSession(context);
|
2021-09-13 09:48:55 +00:00
|
|
|
if (!session?.user?.id) {
|
2021-06-23 15:49:10 +00:00
|
|
|
return { redirect: { permanent: false, destination: "/auth/login" } };
|
|
|
|
}
|
2021-04-07 15:03:02 +00:00
|
|
|
|
2021-08-22 13:16:42 +00:00
|
|
|
const user = await prisma.user.findUnique({
|
|
|
|
where: {
|
2021-07-09 22:59:21 +00:00
|
|
|
id: session.user.id,
|
2021-07-11 19:35:56 +00:00
|
|
|
},
|
2021-08-22 13:16:42 +00:00
|
|
|
select: {
|
|
|
|
id: true,
|
|
|
|
username: true,
|
|
|
|
name: true,
|
|
|
|
email: true,
|
|
|
|
bio: true,
|
|
|
|
avatar: true,
|
|
|
|
timeZone: true,
|
|
|
|
weekStart: true,
|
|
|
|
hideBranding: true,
|
|
|
|
theme: true,
|
2021-09-13 09:48:55 +00:00
|
|
|
plan: true,
|
2021-08-22 13:16:42 +00:00
|
|
|
},
|
|
|
|
});
|
2021-06-23 15:49:10 +00:00
|
|
|
|
2021-09-13 09:48:55 +00:00
|
|
|
if (!user) {
|
|
|
|
throw new Error("User seems logged in but cannot be found in the db");
|
|
|
|
}
|
2021-06-23 15:49:10 +00:00
|
|
|
return {
|
2021-08-22 13:16:42 +00:00
|
|
|
props: {
|
|
|
|
user: {
|
|
|
|
...user,
|
|
|
|
emailMd5: crypto.createHash("md5").update(user.email).digest("hex"),
|
|
|
|
},
|
|
|
|
},
|
2021-06-23 15:49:10 +00:00
|
|
|
};
|
|
|
|
};
|