Prechádzať zdrojové kódy

Throw Error when mailer setup is not complete

Shun Miyazawa 3 rokov pred
rodič
commit
d0bb179a49

+ 11 - 1
packages/app/src/server/routes/apiv3/user-activation.ts

@@ -186,6 +186,11 @@ async function makeRegistrationEmailToken(email, crowi) {
     appService,
   } = crowi;
 
+  const isMailerSetup = mailService.isMailerSetup ?? false;
+  if (!isMailerSetup) {
+    throw Error('mailService is not setup');
+  }
+
   const grobalLang = configManager.getConfig('crowi', 'app:globalLang');
   const i18n = grobalLang;
   const appUrl = appService.getSiteUrl();
@@ -224,7 +229,12 @@ export const registerAction = (crowi) => {
       return res.apiv3Err(['message.email_address_is_already_registered'], 400);
     }
 
-    makeRegistrationEmailToken(email, crowi);
+    try {
+      await makeRegistrationEmailToken(email, crowi);
+    }
+    catch (err) {
+      return res.apiv3Err(err);
+    }
 
     return res.apiv3({ redirectTo: '/login#register' });
   };