Przeglądaj źródła

Merge pull request #1461 from weseek/reactify-admin/enable-mail-setting

Reactify admin/enable mail setting
yusuketk 6 lat temu
rodzic
commit
4c6b563dc9

+ 2 - 2
src/client/js/app.jsx

@@ -37,7 +37,7 @@ import TableOfContents from './components/TableOfContents';
 import UserGroupDetailPage from './components/Admin/UserGroupDetail/UserGroupDetailPage';
 import MarkdownSetting from './components/Admin/MarkdownSetting/MarkDownSetting';
 import UserManagement from './components/Admin/UserManagement';
-import AppSettingPage from './components/Admin/App/AppSettingPage';
+import AppSettingsPage from './components/Admin/App/AppSettingsPage';
 import ManageExternalAccount from './components/Admin/ManageExternalAccount';
 import UserGroupPage from './components/Admin/UserGroup/UserGroupPage';
 import Customize from './components/Admin/Customize/Customize';
@@ -176,7 +176,7 @@ if (adminAppElem != null) {
   ReactDOM.render(
     <Provider inject={[injectableContainers, adminAppContainer]}>
       <I18nextProvider i18n={i18n}>
-        <AppSettingPage />
+        <AppSettingsPage />
       </I18nextProvider>
     </Provider>,
     adminAppElem,

+ 5 - 5
src/client/js/components/Admin/App/AppSettingPage.jsx → src/client/js/components/Admin/App/AppSettingsPage.jsx

@@ -17,7 +17,7 @@ import PluginSetting from './PluginSetting';
 
 const logger = loggerFactory('growi:appSettings');
 
-class AppSettingPage extends React.Component {
+class AppSettingsPage extends React.Component {
 
   async componentDidMount() {
     const { adminAppContainer } = this.props;
@@ -77,7 +77,7 @@ class AppSettingPage extends React.Component {
 
 }
 
-AppSettingPage.propTypes = {
+AppSettingsPage.propTypes = {
   t: PropTypes.func.isRequired, // i18next
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
   adminAppContainer: PropTypes.instanceOf(AdminAppContainer).isRequired,
@@ -86,9 +86,9 @@ AppSettingPage.propTypes = {
 /**
  * Wrapper component for using unstated
  */
-const AppSettingPageWrapper = (props) => {
-  return createSubscribedElement(AppSettingPage, props, [AppContainer, AdminAppContainer]);
+const AppSettingsPageWrapper = (props) => {
+  return createSubscribedElement(AppSettingsPage, props, [AppContainer, AdminAppContainer]);
 };
 
 
-export default withTranslation()(AppSettingPageWrapper);
+export default withTranslation()(AppSettingsPageWrapper);

+ 33 - 12
src/client/js/components/Admin/App/MailSetting.jsx

@@ -1,23 +1,39 @@
 import React from 'react';
 import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
+import loggerFactory from '@alias/logger';
 
 import { createSubscribedElement } from '../../UnstatedUtils';
+import { toastSuccess, toastError } from '../../../util/apiNotification';
 
 import AppContainer from '../../../services/AppContainer';
+import AdminAppContainer from '../../../services/AdminAppContainer';
+
+const logger = loggerFactory('growi:appSettings');
 
 class MailSetting extends React.Component {
 
   constructor(props) {
     super(props);
 
-    this.state = {
-    };
+    this.submitHandler = this.submitHandler.bind(this);
   }
 
+  async submitHandler() {
+    const { t, adminAppContainer } = this.props;
+
+    try {
+      await adminAppContainer.updateMailSettingHandler();
+      toastSuccess(t('app_setting.updated_app_setting'));
+    }
+    catch (err) {
+      toastError(err);
+      logger.error(err);
+    }
+  }
 
   render() {
-    const { t } = this.props;
+    const { t, adminAppContainer } = this.props;
 
     return (
       <React.Fragment>
@@ -32,8 +48,9 @@ class MailSetting extends React.Component {
                   id="settingForm[mail.from]"
                   type="text"
                   name="settingForm[mail:from]"
-                  placeholder="{{ t('eg') }} mail@growi.org"
-                  value="{{ getConfig('crowi', 'mail:from') | default('') }}"
+                  placeholder={`${t('eg')} mail@growi.org`}
+                  defaultValue={adminAppContainer.state.fromAddress}
+                  onChange={(e) => { adminAppContainer.changeFromAddress(e.target.value) }}
                 />
               </div>
             </div>
@@ -50,7 +67,8 @@ class MailSetting extends React.Component {
                   className="form-control"
                   type="text"
                   name="settingForm[mail:smtpHost]"
-                  value="{{ getConfig('crowi', 'mail:smtpHost') | default('') }}"
+                  defaultValue={adminAppContainer.state.smtpHost}
+                  onChange={(e) => { adminAppContainer.changeSmtpHost(e.target.value) }}
                 />
               </div>
               <div className="col-xs-2">
@@ -59,7 +77,8 @@ class MailSetting extends React.Component {
                   className="form-control"
                   type="text"
                   name="settingForm[mail:smtpPort]"
-                  value="{{ getConfig('crowi', 'mail:smtpPort') | default('') }}"
+                  defaultValue={adminAppContainer.state.smtpPort}
+                  onChange={(e) => { adminAppContainer.changeSmtpPort(e.target.value) }}
                 />
               </div>
             </div>
@@ -75,7 +94,8 @@ class MailSetting extends React.Component {
                   className="form-control"
                   type="text"
                   name="settingForm[mail:smtpUser]"
-                  value="{{ getConfig('crowi', 'mail:smtpUser') | default('') }}"
+                  defaultValue={adminAppContainer.state.SmtpUser}
+                  onChange={(e) => { adminAppContainer.changeSmtpUser(e.target.value) }}
                 />
               </div>
               <div className="col-xs-3">
@@ -84,7 +104,8 @@ class MailSetting extends React.Component {
                   className="form-control"
                   type="password"
                   name="settingForm[mail:smtpPassword]"
-                  value="{{ getConfig('crowi', 'mail:smtpPassword') | default('') }}"
+                  defaultValue={adminAppContainer.state.smtpPassword}
+                  onChange={(e) => { adminAppContainer.changeSmtpPassword(e.target.value) }}
                 />
               </div>
             </div>
@@ -95,8 +116,7 @@ class MailSetting extends React.Component {
           <div className="col-md-12">
             <div className="form-group">
               <div className="col-xs-offset-3 col-xs-6">
-                <input type="hidden" name="_csrf" value="{{ csrf() }}" />
-                <button type="submit" className="btn btn-primary">
+                <button type="submit" className="btn btn-primary" onClick={this.submitHandler}>
                   {t('app_setting.Update')}
                 </button>
               </div>
@@ -113,12 +133,13 @@ class MailSetting extends React.Component {
  * Wrapper component for using unstated
  */
 const MailSettingWrapper = (props) => {
-  return createSubscribedElement(MailSetting, props, [AppContainer]);
+  return createSubscribedElement(MailSetting, props, [AppContainer, AdminAppContainer]);
 };
 
 MailSetting.propTypes = {
   t: PropTypes.func.isRequired, // i18next
   appContainer: PropTypes.instanceOf(AppContainer).isRequired,
+  adminAppContainer: PropTypes.instanceOf(AdminAppContainer).isRequired,
 };
 
 export default withTranslation()(MailSettingWrapper);

+ 79 - 10
src/client/js/services/AdminAppContainer.js

@@ -25,6 +25,11 @@ export default class AdminAppContainer extends Container {
       siteUrl: '',
       envSiteUrl: '',
       isSetSiteUrl: true,
+      fromAddress: '',
+      smtpHost: '',
+      smtpPort: '',
+      smtpUser: '',
+      smtpPassword: '',
     };
 
     this.changeTitle = this.changeTitle.bind(this);
@@ -32,8 +37,14 @@ export default class AdminAppContainer extends Container {
     this.changeGlobalLang = this.changeGlobalLang.bind(this);
     this.changeFileUpload = this.changeFileUpload.bind(this);
     this.changeSiteUrl = this.changeSiteUrl.bind(this);
+    this.changeFromAddress = this.changeFromAddress.bind(this);
+    this.changeSmtpHost = this.changeSmtpHost.bind(this);
+    this.changeSmtpPort = this.changeSmtpPort.bind(this);
+    this.changeSmtpUser = this.changeSmtpUser.bind(this);
+    this.changeSmtpPassword = this.changeSmtpPassword.bind(this);
     this.updateAppSettingHandler = this.updateAppSettingHandler.bind(this);
     this.updateSiteUrlSettingHandler = this.updateSiteUrlSettingHandler.bind(this);
+    this.updateMailSettingHandler = this.updateMailSettingHandler.bind(this);
   }
 
   /**
@@ -49,16 +60,21 @@ export default class AdminAppContainer extends Container {
   async retrieveAppSettingsData() {
     try {
       const response = await this.appContainer.apiv3.get('/app-settings/');
-      const { appSettingParams } = response.data;
+      const { appSettingsParams } = response.data;
 
       this.setState({
-        title: appSettingParams.title,
-        confidential: appSettingParams.confidential,
-        globalLang: appSettingParams.globalLang,
-        fileUpload: appSettingParams.fileUpload,
-        siteUrl: appSettingParams.siteUrl,
-        envSiteUrl: appSettingParams.envSiteUrl,
-        isSetSiteUrl: !!appSettingParams.siteUrl,
+        title: appSettingsParams.title,
+        confidential: appSettingsParams.confidential,
+        globalLang: appSettingsParams.globalLang,
+        fileUpload: appSettingsParams.fileUpload,
+        siteUrl: appSettingsParams.siteUrl,
+        envSiteUrl: appSettingsParams.envSiteUrl,
+        isSetSiteUrl: !!appSettingsParams.siteUrl,
+        fromAddress: appSettingsParams.fromAddress,
+        smtpHost: appSettingsParams.smtpHost,
+        smtpPort: appSettingsParams.smtpPort,
+        smtpUser: appSettingsParams.smtpUser,
+        smtpPassword: appSettingsParams.smtpPassword,
       });
 
     }
@@ -103,6 +119,42 @@ export default class AdminAppContainer extends Container {
     this.setState({ siteUrl });
   }
 
+
+  /**
+   * Change from address
+   */
+  changeFromAddress(fromAddress) {
+    this.setState({ fromAddress });
+  }
+
+  /**
+   * Change smtp host
+   */
+  changeSmtpHost(smtpHost) {
+    this.setState({ smtpHost });
+  }
+
+  /**
+   * Change smtp port
+   */
+  changeSmtpPort(smtpPort) {
+    this.setState({ smtpPort });
+  }
+
+  /**
+   * Change smtp user
+   */
+  changeSmtpUser(smtpUser) {
+    this.setState({ smtpUser });
+  }
+
+  /**
+   * Change smtp password
+   */
+  changeSmtpPassword(smtpPassword) {
+    this.setState({ smtpPassword });
+  }
+
   /**
    * Update app setting
    * @memberOf AdminAppContainer
@@ -129,8 +181,25 @@ export default class AdminAppContainer extends Container {
     const response = await this.appContainer.apiv3.put('/app-settings/site-url-setting', {
       siteUrl: this.state.siteUrl,
     });
-    const { appSettingParams } = response.data;
-    return appSettingParams;
+    const { siteUrlSettingParams } = response.data;
+    return siteUrlSettingParams;
+  }
+
+  /**
+   * Update mail setting
+   * @memberOf AdminAppContainer
+   * @return {Array} Appearance
+   */
+  async updateMailSettingHandler() {
+    const response = await this.appContainer.apiv3.put('/app-settings/mail-setting', {
+      fromAddress: this.state.fromAddress,
+      smtpHost: this.state.smtpHost,
+      smtpPort: this.state.smtpPort,
+      smtpUser: this.state.smtpUser,
+      smtpPassword: this.state.smtpPassword,
+    });
+    const { mailSettingParams } = response.data;
+    return mailSettingParams;
   }
 
 }

+ 3 - 64
src/server/routes/admin.js

@@ -573,46 +573,12 @@ module.exports = function(crowi, app) {
     if (req.form.isValid) {
       debug('form content', form);
 
-      // mail setting ならここで validation
-      if (form['mail:from']) {
-        validateMailSetting(req, form, async(err, data) => {
-          debug('Error validate mail setting: ', err, data);
-          if (err) {
-            req.form.errors.push('SMTPを利用したテストメール送信に失敗しました。設定をみなおしてください。');
-            return res.json({ status: false, message: req.form.errors.join('\n') });
-          }
-
-          await configManager.updateConfigsInTheSameNamespace('crowi', form);
-          return res.json({ status: true });
-        });
-      }
-      else {
-        await configManager.updateConfigsInTheSameNamespace('crowi', form);
-        return res.json({ status: true });
-      }
-    }
-    else {
-      return res.json({ status: false, message: req.form.errors.join('\n') });
-    }
-  };
-
-  actions.api.asyncAppSetting = async(req, res) => {
-    const form = req.form.settingForm;
-
-    if (!req.form.isValid) {
-      return res.json({ status: false, message: req.form.errors.join('\n') });
-    }
-
-    debug('form content', form);
-
-    try {
       await configManager.updateConfigsInTheSameNamespace('crowi', form);
       return res.json({ status: true });
     }
-    catch (err) {
-      logger.error(err);
-      return res.json({ status: false });
-    }
+
+    return res.json({ status: false, message: req.form.errors.join('\n') });
+
   };
 
   actions.api.securitySetting = async function(req, res) {
@@ -1063,33 +1029,6 @@ module.exports = function(crowi, app) {
     return res.json(ApiResponse.success());
   };
 
-  function validateMailSetting(req, form, callback) {
-    const mailer = crowi.mailer;
-    const option = {
-      host: form['mail:smtpHost'],
-      port: form['mail:smtpPort'],
-    };
-    if (form['mail:smtpUser'] && form['mail:smtpPassword']) {
-      option.auth = {
-        user: form['mail:smtpUser'],
-        pass: form['mail:smtpPassword'],
-      };
-    }
-    if (option.port === 465) {
-      option.secure = true;
-    }
-
-    const smtpClient = mailer.createSMTPClient(option);
-    debug('mailer setup for validate SMTP setting', smtpClient);
-
-    smtpClient.sendMail({
-      from: form['mail:from'],
-      to: req.user.email,
-      subject: 'Wiki管理設定のアップデートによるメール通知',
-      text: 'このメールは、WikiのSMTP設定のアップデートにより送信されています。',
-    }, callback);
-  }
-
   /**
    * validate setting form values for SAML
    *

+ 171 - 65
src/server/routes/apiv3/app-settings.js

@@ -2,6 +2,8 @@ const loggerFactory = require('@alias/logger');
 
 const logger = loggerFactory('growi:routes:apiv3:app-settings');
 
+const debug = require('debug')('growi:routes:admin');
+
 const express = require('express');
 
 const router = express.Router();
@@ -20,6 +22,13 @@ const validator = {
   siteUrlSetting: [
     body('siteUrl').trim(),
   ],
+  mailSetting: [
+    body('fromAddress').trim(),
+    body('smtpHost').trim(),
+    body('smtpPort').trim(),
+    body('smtpUser').trim(),
+    body('smtpPassword').trim(),
+  ],
 };
 
 
@@ -49,12 +58,33 @@ const validator = {
  *          fileUpload:
  *            type: boolean
  *            description: enable upload file except image file
+ *     SiteUrlSettingParams:
+ *        type: object
+ *        properties:
  *          siteUrl:
  *            type: String
  *            description: Site URL. e.g. https://example.com, https://example.com:8080
  *          envSiteUrl:
  *            type: String
  *            description: environment variable 'APP_SITE_URL'
+ *     MailSettingParams:
+ *        type: object
+ *        properties:
+ *          fromAddress:
+ *            type: String
+ *            description: e-mail address used as from address of mail which sent from GROWI app
+ *          smtpHost:
+ *            type: String
+ *            description: host name of client's smtp server
+ *          smtpPort:
+ *            type: String
+ *            description: port of client's smtp server
+ *          smtpUser:
+ *            type: String
+ *            description: user name of client's smtp server
+ *          smtpPassword:
+ *            type: String
+ *            description: password of client's smtp server
  */
 
 module.exports = (crowi) => {
@@ -80,35 +110,25 @@ module.exports = (crowi) => {
    *              application/json:
    *                schema:
    *                  properties:
-   *                    title:
-   *                      type: String
-   *                      description: site name show on page header and tilte of HTML
-   *                    confidential:
-   *                      type: String
-   *                      description: confidential show on page header
-   *                    globalLang:
-   *                      type: String
-   *                      description: language set when create user
-   *                    fileUpload:
-   *                      type: boolean
-   *                      description: enable upload file except image file
-   *                    siteUrl:
-   *                      type: String
-   *                      description: Site URL. e.g. https://example.com, https://example.com:8080
-   *                    envSiteUrl:
-   *                      type: String
-   *                      description: environment variable 'APP_SITE_URL'
+   *                    appSettingsParams:
+   *                      type: object
+   *                      description: app settings params
    */
   router.get('/', accessTokenParser, loginRequired, adminRequired, async(req, res) => {
-    const appSettingParams = {
+    const appSettingsParams = {
       title: crowi.configManager.getConfig('crowi', 'app:title'),
       confidential: crowi.configManager.getConfig('crowi', 'app:confidential'),
       globalLang: crowi.configManager.getConfig('crowi', 'app:globalLang'),
       fileUpload: crowi.configManager.getConfig('crowi', 'app:fileUpload'),
       siteUrl: crowi.configManager.getConfig('crowi', 'app:siteUrl'),
       envSiteUrl: crowi.configManager.getConfigFromEnvVars('crowi', 'app:siteUrl'),
+      fromAddress: crowi.configManager.getConfig('crowi', 'mail:from'),
+      smtpHost: crowi.configManager.getConfig('crowi', 'mail:smtpHost'),
+      smtpPort: crowi.configManager.getConfig('crowi', 'mail:smtpPort'),
+      smtpUser: crowi.configManager.getConfig('crowi', 'mail:smtpUser'),
+      smtpPassword: crowi.configManager.getConfig('crowi', 'mail:smtpPassword'),
     };
-    return res.apiv3({ appSettingParams });
+    return res.apiv3({ appSettingsParams });
 
   });
 
@@ -125,29 +145,14 @@ module.exports = (crowi) => {
    *          content:
    *            application/json:
    *              schema:
-   *                type: object
-   *                properties:
-   *                  title:
-   *                    type: String
-   *                    description: site name show on page header and tilte of HTML
-   *                  confidential:
-   *                    type: String
-   *                    description: confidential show on page header
-   *                  globalLang:
-   *                    type: String
-   *                    description: language set when create user
-   *                  fileUpload:
-   *                    type: boolean
-   *                    description: enable upload file except image file
+   *                $ref: '#/components/schemas/AppSettingParams'
    *        responses:
    *          200:
    *            description: Succeeded to update app setting
    *            content:
    *              application/json:
    *                schema:
-   *                  properties:
-   *                    status:
-   *                      $ref: '#/components/schemas/appSettingParams'
+   *                  $ref: '#/components/schemas/AppSettingParams'
    */
   router.put('/app-setting', loginRequiredStrictly, adminRequired, csrf, validator.appSetting, ApiV3FormValidator, async(req, res) => {
     const requestAppSettingParams = {
@@ -176,32 +181,26 @@ module.exports = (crowi) => {
   });
 
   /**
- * @swagger
- *
- *    /app-settings/site-url-setting:
- *      put:
- *        tags: [AppSettings]
- *        description: Update site url setting
- *        requestBody:
- *          required: true
- *          content:
- *            application/json:
- *              schema:
- *                type: object
- *                properties:
- *                  siteUrl:
- *                    type: String
- *                    description: Site URL. e.g. https://example.com, https://example.com:8080
- *        responses:
- *          200:
- *            description: Succeeded to update site url setting
- *            content:
- *              application/json:
- *                schema:
- *                  properties:
- *                    status:
- *                      $ref: '#/components/schemas/appSettingParams'
- */
+   * @swagger
+   *
+   *    /app-settings/site-url-setting:
+   *      put:
+   *        tags: [AppSettings]
+   *        description: Update site url setting
+   *        requestBody:
+   *          required: true
+   *          content:
+   *            application/json:
+   *              schema:
+   *                $ref: '#/components/schemas/SiteUrlSettingParams'
+   *        responses:
+   *          200:
+   *            description: Succeeded to update site url setting
+   *            content:
+   *              application/json:
+   *                schema:
+   *                  $ref: '#/components/schemas/SiteUrlSettingParams'
+   */
   router.put('/site-url-setting', loginRequiredStrictly, adminRequired, csrf, validator.siteUrlSetting, ApiV3FormValidator, async(req, res) => {
 
     const requestSiteUrlSettingParams = {
@@ -210,10 +209,10 @@ module.exports = (crowi) => {
 
     try {
       await crowi.configManager.updateConfigsInTheSameNamespace('crowi', requestSiteUrlSettingParams);
-      const appSettingParams = {
+      const siteUrlSettingParams = {
         siteUrl: crowi.configManager.getConfig('crowi', 'app:siteUrl'),
       };
-      return res.apiv3({ appSettingParams });
+      return res.apiv3({ siteUrlSettingParams });
     }
     catch (err) {
       const msg = 'Error occurred in updating site url setting';
@@ -223,6 +222,113 @@ module.exports = (crowi) => {
 
   });
 
+  /**
+   * send mail (Promise wrapper)
+   */
+  async function sendMailPromiseWrapper(smtpClient, options) {
+    return new Promise((resolve, reject) => {
+      smtpClient.sendMail(options, (err, res) => {
+        if (err) {
+          reject(err);
+        }
+        else {
+          resolve(res);
+        }
+      });
+    });
+  }
+
+  /**
+   * validate mail setting send test mail
+   */
+  async function validateMailSetting(req) {
+    const mailer = crowi.mailer;
+    const option = {
+      host: req.body.smtpHost,
+      port: req.body.smtpPort,
+    };
+    if (req.body.smtpUser && req.body.smtpPassword) {
+      option.auth = {
+        user: req.body.smtpUser,
+        pass: req.body.smtpPassword,
+      };
+    }
+    if (option.port === 465) {
+      option.secure = true;
+    }
+
+    const smtpClient = mailer.createSMTPClient(option);
+    debug('mailer setup for validate SMTP setting', smtpClient);
+
+    const mailOptions = {
+      from: req.body.fromAddress,
+      to: req.user.email,
+      subject: 'Wiki管理設定のアップデートによるメール通知',
+      text: 'このメールは、WikiのSMTP設定のアップデートにより送信されています。',
+    };
+
+    await sendMailPromiseWrapper(smtpClient, mailOptions);
+  }
+
+  /**
+   * @swagger
+   *
+   *    /app-settings/site-url-setting:
+   *      put:
+   *        tags: [AppSettings]
+   *        description: Update site url setting
+   *        requestBody:
+   *          required: true
+   *          content:
+   *            application/json:
+   *              schema:
+   *                $ref: '#/components/schemas/MailSettingParams'
+   *        responses:
+   *          200:
+   *            description: Succeeded to update site url setting
+   *            content:
+   *              application/json:
+   *                schema:
+   *                  $ref: '#/components/schemas/MailSettingParams'
+   */
+  router.put('/mail-setting', loginRequiredStrictly, adminRequired, csrf, validator.mailSetting, ApiV3FormValidator, async(req, res) => {
+    // テストメール送信によるバリデート
+    try {
+      await validateMailSetting(req);
+    }
+    catch (err) {
+      const msg = 'SMTPを利用したテストメール送信に失敗しました。設定をみなおしてください。';
+      logger.error('Error', err);
+      debug('Error validate mail setting: ', err);
+      return res.apiv3Err(new ErrorV3(msg, 'update-mailSetting-failed'));
+    }
+
+
+    const requestMailSettingParams = {
+      'mail:from': req.body.fromAddress,
+      'mail:smtpHost': req.body.smtpHost,
+      'mail:smtpPort': req.body.smtpPort,
+      'mail:smtpUser': req.body.smtpUser,
+      'mail:smtpPassword': req.body.smtpPassword,
+    };
+
+    try {
+      await crowi.configManager.updateConfigsInTheSameNamespace('crowi', requestMailSettingParams);
+      const mailSettingParams = {
+        fromAddress: crowi.configManager.getConfig('crowi', 'mail:from'),
+        smtpHost: crowi.configManager.getConfig('crowi', 'mail:smtpHost'),
+        smtpPort: crowi.configManager.getConfig('crowi', 'mail:smtpPort'),
+        smtpUser: crowi.configManager.getConfig('crowi', 'mail:smtpUser'),
+        smtpPassword: crowi.configManager.getConfig('crowi', 'mail:smtpPassword'),
+      };
+      return res.apiv3({ mailSettingParams });
+    }
+    catch (err) {
+      const msg = 'Error occurred in updating mail setting';
+      logger.error('Error', err);
+      return res.apiv3Err(new ErrorV3(msg, 'update-mailSetting-failed'));
+    }
+  });
 
   return router;
 };

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

@@ -59,9 +59,6 @@ module.exports = function(crowi, app) {
 
   app.get('/admin'                          , loginRequiredStrictly , adminRequired , admin.index);
   app.get('/admin/app'                      , loginRequiredStrictly , adminRequired , admin.app.index);
-  app.post('/_api/admin/settings/app'       , loginRequiredStrictly , adminRequired , csrf, form.admin.app, admin.api.appSetting);
-  app.post('/_api/admin/settings/siteUrl'   , loginRequiredStrictly , adminRequired , csrf, form.admin.siteUrl, admin.api.asyncAppSetting);
-  app.post('/_api/admin/settings/mail'      , loginRequiredStrictly , adminRequired , csrf, form.admin.mail, admin.api.appSetting);
   app.post('/_api/admin/settings/aws'       , loginRequiredStrictly , adminRequired , csrf, form.admin.aws, admin.api.appSetting);
   app.post('/_api/admin/settings/plugin'    , loginRequiredStrictly , adminRequired , csrf, form.admin.plugin, admin.api.appSetting);