File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed
backend/src/api/controllers Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -70,12 +70,25 @@ export async function sendVerificationEmail(
7070
7171 const userInfo = await UserDAL . getUser ( uid , "request verification email" ) ;
7272
73- const link = await admin . auth ( ) . generateEmailVerificationLink ( email , {
74- url :
75- process . env . MODE === "dev"
76- ? "http://localhost:3000"
77- : "https://monkeytype.com" ,
78- } ) ;
73+ let link = "" ;
74+ try {
75+ link = await admin . auth ( ) . generateEmailVerificationLink ( email , {
76+ url :
77+ process . env . MODE === "dev"
78+ ? "http://localhost:3000"
79+ : "https://monkeytype.com" ,
80+ } ) ;
81+ } catch ( e ) {
82+ if (
83+ e . code === "auth/internal-error" &&
84+ e . message . includes ( "TOO_MANY_ATTEMPTS_TRY_LATER" )
85+ ) {
86+ // for some reason this error is not handled with a custom auth/ code, so we have to do it manually
87+ throw new MonkeyError ( 429 , "Too many requests. Please try again later." ) ;
88+ }
89+ throw e ;
90+ }
91+
7992 await emailQueue . sendVerificationEmail ( email , userInfo . name , link ) ;
8093
8194 return new MonkeyResponse ( "Email sent" ) ;
You can’t perform that action at this time.
0 commit comments