Browse Source

sent an email successfully

kaori 4 years ago
parent
commit
f499726e82
2 changed files with 24 additions and 0 deletions
  1. 23 0
      src/server/routes/forgot-password.js
  2. 1 0
      src/server/routes/index.js

+ 23 - 0
src/server/routes/forgot-password.js

@@ -1,9 +1,32 @@
 module.exports = function(crowi, app) {
+  const { appService, mailService } = crowi;
+  const path = require('path');
   const actions = {};
+  const api = {};
+  actions.api = api;
 
   actions.forgotPassword = async function(req, res) {
     return res.render('forgot-password');
   };
 
+
+  async function sendPasswordResetEmail() {
+    // send mails to all admin users (derived from crowi) -- 2020.06.18 Yuki Takei
+    // const appTitle = appService.getAppTitle();
+
+    return mailService.send({
+      to: 'kaori@weseek.co.jp',
+      subject: 'forgotPasswordMailTest',
+      template: path.join(crowi.localeDir, 'en_US/notifications/passwordReset.txt'),
+    });
+  }
+
+  api.get = async function(req, res) {
+    await sendPasswordResetEmail();
+
+    return;
+  };
+
+
   return actions;
 };

+ 1 - 0
src/server/routes/index.js

@@ -177,6 +177,7 @@ module.exports = function(crowi, app) {
   app.post('/_api/hackmd.saveOnHackmd'   , accessTokenParser , loginRequiredStrictly , csrf, hackmd.validateForApi, hackmd.saveOnHackmd);
 
   app.get('/forgot-password', forgotPassword.forgotPassword);
+  app.get('/forgot-password.get', forgotPassword.api.get);
 
   app.get('/share/:linkId', page.showSharedPage);