Skip to content

Commit 6d360b4

Browse files
committed
chore(auth): address Greptile review — broaden change-email type + migration newline
1 parent 455355d commit 6d360b4

5 files changed

Lines changed: 14 additions & 7 deletions

File tree

apps/sim/components/emails/auth/otp-verification-email.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { getBrandConfig } from '@/ee/whitelabeling'
66
interface OTPVerificationEmailProps {
77
otp: string
88
email?: string
9-
type?: 'sign-in' | 'email-verification' | 'forget-password' | 'chat-access'
9+
type?: 'sign-in' | 'email-verification' | 'change-email' | 'forget-password' | 'chat-access'
1010
chatTitle?: string
1111
}
1212

@@ -16,6 +16,8 @@ const getSubjectByType = (type: string, brandName: string, chatTitle?: string) =
1616
return `Sign in to ${brandName}`
1717
case 'email-verification':
1818
return `Verify your email for ${brandName}`
19+
case 'change-email':
20+
return `Verify your new email for ${brandName}`
1921
case 'forget-password':
2022
return `Reset your ${brandName} password`
2123
case 'chat-access':

apps/sim/components/emails/render.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ interface WorkspaceInvitation {
3939
export async function renderOTPEmail(
4040
otp: string,
4141
email: string,
42-
type: 'sign-in' | 'email-verification' | 'forget-password' = 'email-verification',
42+
type:
43+
| 'sign-in'
44+
| 'email-verification'
45+
| 'change-email'
46+
| 'forget-password' = 'email-verification',
4347
chatTitle?: string
4448
): Promise<string> {
4549
return await render(OTPVerificationEmail({ otp, email, type, chatTitle }))

apps/sim/components/emails/subjects.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { getBrandConfig } from '@/ee/whitelabeling'
44
export type EmailSubjectType =
55
| 'sign-in'
66
| 'email-verification'
7+
| 'change-email'
78
| 'forget-password'
89
| 'reset-password'
910
| 'invitation'
@@ -34,6 +35,8 @@ export function getEmailSubject(type: EmailSubjectType): string {
3435
return `Sign in to ${brandName}`
3536
case 'email-verification':
3637
return `Verify your email for ${brandName}`
38+
case 'change-email':
39+
return `Verify your new email for ${brandName}`
3740
case 'forget-password':
3841
return `Reset your ${brandName} password`
3942
case 'reset-password':

apps/sim/lib/auth/auth.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -910,13 +910,11 @@ export const auth = betterAuth({
910910
)
911911
}
912912

913-
const otpType = data.type === 'change-email' ? 'email-verification' : data.type
914-
915-
const html = await renderOTPEmail(data.otp, data.email, otpType)
913+
const html = await renderOTPEmail(data.otp, data.email, data.type)
916914

917915
const result = await sendEmail({
918916
to: data.email,
919-
subject: getEmailSubject(otpType),
917+
subject: getEmailSubject(data.type),
920918
html,
921919
from: getFromEmailAddress(),
922920
emailType: 'transactional',

packages/db/migrations/0216_colorful_cobalt_man.sql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ ALTER TABLE "subscription" ADD COLUMN "cancel_at" timestamp;--> statement-breakp
33
ALTER TABLE "subscription" ADD COLUMN "canceled_at" timestamp;--> statement-breakpoint
44
ALTER TABLE "subscription" ADD COLUMN "ended_at" timestamp;--> statement-breakpoint
55
ALTER TABLE "subscription" ADD COLUMN "billing_interval" text;--> statement-breakpoint
6-
ALTER TABLE "subscription" ADD COLUMN "stripe_schedule_id" text;
6+
ALTER TABLE "subscription" ADD COLUMN "stripe_schedule_id" text;

0 commit comments

Comments
 (0)