forked from calcom/cal.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Zomars/cal 794 normalize emails in db (calcom#1361)
* Email input UX improvements * Makes email queries case insensitive * Lowercases all emails * Type fixes * Re adds lowercase email to login * Removes citext dependency * Updates schema * Migration fixes * Added failsafes to team invites * Team invite improvements * Deleting the index, lowercasing ``` calendso=> UPDATE users SET email=LOWER(email); ERROR: duplicate key value violates unique constraint "users.email_unique" DETAIL: Key (email)=([email protected]) already exists. ``` vs. ``` calendso=> CREATE UNIQUE INDEX "users.email_unique" ON "users" (email); ERROR: could not create unique index "users.email_unique" DETAIL: Key (email)=([email protected]) is duplicated. ``` I think it'll be easier to rectify for users if they try to run the migrations if the index stays in place. Co-authored-by: Alex van Andel <[email protected]>
- Loading branch information
Showing
15 changed files
with
113 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ import slugify from "@lib/slugify"; | |
import { collectPageParameters, telemetryEventTypes, useTelemetry } from "@lib/telemetry"; | ||
|
||
import CustomBranding from "@components/CustomBranding"; | ||
import { Form } from "@components/form/fields"; | ||
import { EmailInput, Form } from "@components/form/fields"; | ||
import AvatarGroup from "@components/ui/AvatarGroup"; | ||
import { Button } from "@components/ui/Button"; | ||
import PhoneInput from "@components/ui/form/PhoneInput"; | ||
|
@@ -98,9 +98,10 @@ const BookingPage = (props: BookingPageProps) => { | |
|
||
const [guestToggle, setGuestToggle] = useState(false); | ||
|
||
type Location = { type: LocationType; address?: string }; | ||
// it would be nice if Prisma at some point in the future allowed for Json<Location>; as of now this is not the case. | ||
const locations: { type: LocationType }[] = useMemo( | ||
() => (props.eventType.locations as { type: LocationType }[]) || [], | ||
const locations: Location[] = useMemo( | ||
() => (props.eventType.locations as Location[]) || [], | ||
[props.eventType.locations] | ||
); | ||
|
||
|
@@ -171,14 +172,14 @@ const BookingPage = (props: BookingPageProps) => { | |
const { locationType } = booking; | ||
switch (locationType) { | ||
case LocationType.Phone: { | ||
return booking.phone; | ||
return booking.phone || ""; | ||
} | ||
case LocationType.InPerson: { | ||
return locationInfo(locationType).address; | ||
return locationInfo(locationType)?.address || ""; | ||
} | ||
// Catches all other location types, such as Google Meet, Zoom etc. | ||
default: | ||
return selectedLocation; | ||
return selectedLocation || ""; | ||
} | ||
}; | ||
|
||
|
@@ -244,12 +245,12 @@ const BookingPage = (props: BookingPageProps) => { | |
<div className="sm:w-1/2 sm:border-r sm:dark:border-gray-800"> | ||
<AvatarGroup | ||
size={14} | ||
items={[{ image: props.profile.image, alt: props.profile.name }].concat( | ||
items={[{ image: props.profile.image || "", alt: props.profile.name || "" }].concat( | ||
props.eventType.users | ||
.filter((user) => user.name !== props.profile.name) | ||
.map((user) => ({ | ||
image: user.avatar, | ||
title: user.name, | ||
image: user.avatar || "", | ||
alt: user.name || "", | ||
})) | ||
)} | ||
/> | ||
|
@@ -283,8 +284,8 @@ const BookingPage = (props: BookingPageProps) => { | |
)} | ||
<p className="mb-4 text-green-500"> | ||
<CalendarIcon className="inline-block w-4 h-4 mr-1 -mt-1" /> | ||
{date && | ||
parseZone(date).format(timeFormat) + | ||
{(date && parseZone(date)?.format(timeFormat)) || | ||
"No date" + | ||
", " + | ||
dayjs(date).toDate().toLocaleString(i18n.language, { dateStyle: "full" })} | ||
</p> | ||
|
@@ -315,12 +316,8 @@ const BookingPage = (props: BookingPageProps) => { | |
{t("email_address")} | ||
</label> | ||
<div className="mt-1"> | ||
<input | ||
<EmailInput | ||
{...bookingForm.register("email")} | ||
type="email" | ||
name="email" | ||
id="email" | ||
inputMode="email" | ||
required | ||
className="block w-full border-gray-300 rounded-sm shadow-sm dark:bg-black dark:text-white dark:border-gray-900 focus:ring-black focus:border-brand sm:text-sm" | ||
placeholder="[email protected]" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,7 @@ import React, { SyntheticEvent } from "react"; | |
import { getSession } from "@lib/auth"; | ||
import { useLocale } from "@lib/hooks/useLocale"; | ||
|
||
import { TextField } from "@components/form/fields"; | ||
import { EmailField } from "@components/form/fields"; | ||
import { HeadSeo } from "@components/seo/head-seo"; | ||
import Button from "@components/ui/Button"; | ||
|
||
|
@@ -95,14 +95,11 @@ export default function ForgotPassword({ csrfToken }: { csrfToken: string }) { | |
<form className="space-y-6" onSubmit={handleSubmit} action="#"> | ||
<input name="csrfToken" type="hidden" defaultValue={csrfToken} hidden /> | ||
|
||
<TextField | ||
<EmailField | ||
onChange={handleChange} | ||
id="email" | ||
name="email" | ||
label={t("email_address")} | ||
type="email" | ||
inputMode="email" | ||
autoComplete="email" | ||
placeholder="[email protected]" | ||
required | ||
/> | ||
|
Oops, something went wrong.