🚸 Improve magic link sign in experience
New email and sign in feedback
This commit is contained in:
@@ -13,6 +13,7 @@ import { User } from 'db'
|
||||
import { env, getAtPath, isDefined, isNotEmpty } from 'utils'
|
||||
import { mockedUser } from '@/features/auth'
|
||||
import { getNewUserInvitations } from '@/features/auth/api'
|
||||
import { sendVerificationRequest } from './sendVerificationRequest'
|
||||
|
||||
const providers: Provider[] = []
|
||||
|
||||
@@ -42,6 +43,7 @@ if (isNotEmpty(env('SMTP_FROM')) && process.env.SMTP_AUTH_DISABLED !== 'true')
|
||||
},
|
||||
},
|
||||
from: env('SMTP_FROM'),
|
||||
sendVerificationRequest,
|
||||
})
|
||||
)
|
||||
|
||||
|
||||
16
apps/builder/src/pages/api/auth/sendVerificationRequest.ts
Normal file
16
apps/builder/src/pages/api/auth/sendVerificationRequest.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { EmailConfig } from 'next-auth/providers/email'
|
||||
import { sendMagicLinkEmail } from 'emails'
|
||||
|
||||
type Props = {
|
||||
identifier: string
|
||||
url: string
|
||||
provider: Partial<Omit<EmailConfig, 'options'>>
|
||||
}
|
||||
|
||||
export const sendVerificationRequest = async ({ identifier, url }: Props) => {
|
||||
try {
|
||||
await sendMagicLinkEmail({ url, to: identifier })
|
||||
} catch (err) {
|
||||
throw new Error(`Email(s) could not be sent`)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user