itizawa 6 лет назад
Родитель
Сommit
447424d609

+ 26 - 26
src/client/js/components/Admin/Security/GoogleSecuritySetting.jsx

@@ -39,10 +39,10 @@ class GoogleSecurityManagement extends React.Component {
   }
   }
 
 
   async onClickSubmit() {
   async onClickSubmit() {
-    const { t, adminGeneralSecurityContainer, adminGoogleSecurityContainer } = this.props;
+    const { t, adminGoogleSecurityContainer } = this.props;
 
 
     try {
     try {
-      await adminGoogleSecurityContainer.updateGoogleSetting(adminGeneralSecurityContainer.state.isGoogleOAuthEnabled);
+      await adminGoogleSecurityContainer.updateGoogleSetting();
       toastSuccess(t('security_setting.OAuth.Google.updated_google'));
       toastSuccess(t('security_setting.OAuth.Google.updated_google'));
     }
     }
     catch (err) {
     catch (err) {
@@ -58,17 +58,17 @@ class GoogleSecurityManagement extends React.Component {
       <React.Fragment>
       <React.Fragment>
 
 
         <h2 className="alert-anchor border-bottom">
         <h2 className="alert-anchor border-bottom">
-          { t('security_setting.OAuth.Google.name') } { t('security_setting.configuration') }
+          {t('security_setting.OAuth.Google.name')} {t('security_setting.configuration')}
         </h2>
         </h2>
 
 
         {this.state.retrieveError != null && (
         {this.state.retrieveError != null && (
-        <div className="alert alert-danger">
-          <p>{t('Error occurred')} : {this.state.err}</p>
-        </div>
+          <div className="alert alert-danger">
+            <p>{t('Error occurred')} : {this.state.err}</p>
+          </div>
         )}
         )}
 
 
         <div className="row mb-5">
         <div className="row mb-5">
-          <strong className="col-xs-3 text-right">{ t('security_setting.OAuth.Google.name') }</strong>
+          <strong className="col-xs-3 text-right">{t('security_setting.OAuth.Google.name')}</strong>
           <div className="col-xs-6 text-left">
           <div className="col-xs-6 text-left">
             <div className="checkbox checkbox-success">
             <div className="checkbox checkbox-success">
               <input
               <input
@@ -78,14 +78,14 @@ class GoogleSecurityManagement extends React.Component {
                 onChange={() => { adminGeneralSecurityContainer.switchIsGoogleOAuthEnabled() }}
                 onChange={() => { adminGeneralSecurityContainer.switchIsGoogleOAuthEnabled() }}
               />
               />
               <label htmlFor="isGoogleEnabled">
               <label htmlFor="isGoogleEnabled">
-                { t('security_setting.OAuth.Google.enable_google') }
+                {t('security_setting.OAuth.Google.enable_google')}
               </label>
               </label>
             </div>
             </div>
           </div>
           </div>
         </div>
         </div>
 
 
         <div className="row mb-5">
         <div className="row mb-5">
-          <label className="col-xs-3 text-right">{ t('security_setting.callback_URL') }</label>
+          <label className="col-xs-3 text-right">{t('security_setting.callback_URL')}</label>
           <div className="col-xs-6">
           <div className="col-xs-6">
             <input
             <input
               className="form-control"
               className="form-control"
@@ -93,15 +93,15 @@ class GoogleSecurityManagement extends React.Component {
               value={adminGoogleSecurityContainer.state.callbackUrl}
               value={adminGoogleSecurityContainer.state.callbackUrl}
               readOnly
               readOnly
             />
             />
-            <p className="help-block small">{ t('security_setting.desc_of_callback_URL', { AuthName: 'OAuth' }) }</p>
+            <p className="help-block small">{t('security_setting.desc_of_callback_URL', { AuthName: 'OAuth' })}</p>
             {!adminGeneralSecurityContainer.state.appSiteUrl && (
             {!adminGeneralSecurityContainer.state.appSiteUrl && (
-            <div className="alert alert-danger">
-              <i
-                className="icon-exclamation"
-                // eslint-disable-next-line max-len
-                dangerouslySetInnerHTML={{ __html: t('security_setting.alert_siteUrl_is_not_set', { link: `<a href="/admin/app">${t('App settings')}<i class="icon-login"></i></a>` }) }}
-              />
-            </div>
+              <div className="alert alert-danger">
+                <i
+                  className="icon-exclamation"
+                  // eslint-disable-next-line max-len
+                  dangerouslySetInnerHTML={{ __html: t('security_setting.alert_siteUrl_is_not_set', { link: `<a href="/admin/app">${t('App settings')}<i class="icon-login"></i></a>` }) }}
+                />
+              </div>
             )}
             )}
           </div>
           </div>
         </div>
         </div>
@@ -111,7 +111,7 @@ class GoogleSecurityManagement extends React.Component {
           <React.Fragment>
           <React.Fragment>
 
 
             <div className="row mb-5">
             <div className="row mb-5">
-              <label htmlFor="googleClientId" className="col-xs-3 text-right">{ t('security_setting.clientID') }</label>
+              <label htmlFor="googleClientId" className="col-xs-3 text-right">{t('security_setting.clientID')}</label>
               <div className="col-xs-6">
               <div className="col-xs-6">
                 <input
                 <input
                   className="form-control"
                   className="form-control"
@@ -127,7 +127,7 @@ class GoogleSecurityManagement extends React.Component {
             </div>
             </div>
 
 
             <div className="row mb-5">
             <div className="row mb-5">
-              <label htmlFor="googleClientSecret" className="col-xs-3 text-right">{ t('security_setting.client_secret') }</label>
+              <label htmlFor="googleClientSecret" className="col-xs-3 text-right">{t('security_setting.client_secret')}</label>
               <div className="col-xs-6">
               <div className="col-xs-6">
                 <input
                 <input
                   className="form-control"
                   className="form-control"
@@ -167,7 +167,7 @@ class GoogleSecurityManagement extends React.Component {
 
 
         <div className="row my-3">
         <div className="row my-3">
           <div className="col-xs-offset-3 col-xs-5">
           <div className="col-xs-offset-3 col-xs-5">
-            <button type="button" className="btn btn-primary" disabled={this.state.retrieveError != null} onClick={this.onClickSubmit}>{ t('Update') }</button>
+            <button type="button" className="btn btn-primary" disabled={this.state.retrieveError != null} onClick={this.onClickSubmit}>{t('Update')}</button>
           </div>
           </div>
         </div>
         </div>
 
 
@@ -176,15 +176,15 @@ class GoogleSecurityManagement extends React.Component {
         <div style={{ minHeight: '300px' }}>
         <div style={{ minHeight: '300px' }}>
           <h4>
           <h4>
             <i className="icon-question" aria-hidden="true"></i>
             <i className="icon-question" aria-hidden="true"></i>
-            <a href="#collapseHelpForGoogleOauth" data-toggle="collapse"> { t('security_setting.OAuth.how_to.google') }</a>
+            <a href="#collapseHelpForGoogleOauth" data-toggle="collapse"> {t('security_setting.OAuth.how_to.google')}</a>
           </h4>
           </h4>
           <ol id="collapseHelpForGoogleOauth" className="collapse">
           <ol id="collapseHelpForGoogleOauth" className="collapse">
             {/* eslint-disable-next-line max-len */}
             {/* eslint-disable-next-line max-len */}
-            <li dangerouslySetInnerHTML={{ __html:  t('security_setting.OAuth.Google.register_1', { link: '<a href="https://console.cloud.google.com/apis/credentials" target=_blank>Google Cloud Platform API Manager</a>' }) }} />
-            <li dangerouslySetInnerHTML={{ __html:  t('security_setting.OAuth.Google.register_2') }} />
-            <li dangerouslySetInnerHTML={{ __html:  t('security_setting.OAuth.Google.register_3') }} />
-            <li dangerouslySetInnerHTML={{ __html:  t('security_setting.OAuth.Google.register_4', { url: adminGoogleSecurityContainer.state.callbackUrl }) }} />
-            <li dangerouslySetInnerHTML={{ __html:  t('security_setting.OAuth.Google.register_5') }} />
+            <li dangerouslySetInnerHTML={{ __html: t('security_setting.OAuth.Google.register_1', { link: '<a href="https://console.cloud.google.com/apis/credentials" target=_blank>Google Cloud Platform API Manager</a>' }) }} />
+            <li dangerouslySetInnerHTML={{ __html: t('security_setting.OAuth.Google.register_2') }} />
+            <li dangerouslySetInnerHTML={{ __html: t('security_setting.OAuth.Google.register_3') }} />
+            <li dangerouslySetInnerHTML={{ __html: t('security_setting.OAuth.Google.register_4', { url: adminGoogleSecurityContainer.state.callbackUrl }) }} />
+            <li dangerouslySetInnerHTML={{ __html: t('security_setting.OAuth.Google.register_5') }} />
           </ol>
           </ol>
         </div>
         </div>
 
 

+ 1 - 2
src/client/js/services/AdminGoogleSecurityContainer.js

@@ -73,10 +73,9 @@ export default class AdminGoogleSecurityContainer extends Container {
   /**
   /**
    * Update googleSetting
    * Update googleSetting
    */
    */
-  async updateGoogleSetting(isGoogleOAuthEnabled) {
+  async updateGoogleSetting() {
 
 
     const response = await this.appContainer.apiv3.put('/security-setting/google-oauth', {
     const response = await this.appContainer.apiv3.put('/security-setting/google-oauth', {
-      isGoogleOAuthEnabled,
       googleClientId: this.state.googleClientId,
       googleClientId: this.state.googleClientId,
       googleClientSecret: this.state.googleClientSecret,
       googleClientSecret: this.state.googleClientSecret,
       isSameUsernameTreatedAsIdenticalUser: this.state.isSameUsernameTreatedAsIdenticalUser,
       isSameUsernameTreatedAsIdenticalUser: this.state.isSameUsernameTreatedAsIdenticalUser,

+ 0 - 5
src/server/routes/apiv3/security-setting.js

@@ -60,7 +60,6 @@ const validator = {
     body('isSameUsernameTreatedAsIdenticalUser').isBoolean(),
     body('isSameUsernameTreatedAsIdenticalUser').isBoolean(),
   ],
   ],
   googleOAuth: [
   googleOAuth: [
-    body('isGoogleOAuthEnabled').isBoolean(),
     body('googleClientId').isString(),
     body('googleClientId').isString(),
     body('googleClientSecret').isString(),
     body('googleClientSecret').isString(),
     body('isSameUsernameTreatedAsIdenticalUser').isBoolean(),
     body('isSameUsernameTreatedAsIdenticalUser').isBoolean(),
@@ -221,9 +220,6 @@ const validator = {
  *            description: local account automatically linked the email matched
  *            description: local account automatically linked the email matched
  *      GitHubOAuthSetting:
  *      GitHubOAuthSetting:
  *        type:object
  *        type:object
- *          isGoogleOAuthEnabled:
- *            type: boolean
- *            description: whether to enable google oauth
  *          githubClientId:
  *          githubClientId:
  *            type: string
  *            type: string
  *            description: key of comsumer
  *            description: key of comsumer
@@ -657,7 +653,6 @@ module.exports = (crowi) => {
    */
    */
   router.put('/google-oauth', loginRequiredStrictly, adminRequired, csrf, validator.googleOAuth, ApiV3FormValidator, async(req, res) => {
   router.put('/google-oauth', loginRequiredStrictly, adminRequired, csrf, validator.googleOAuth, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
     const requestParams = {
-      'security:passport-google:isEnabled': req.body.isEnabled,
       'security:passport-google:clientId': req.body.googleClientId,
       'security:passport-google:clientId': req.body.googleClientId,
       'security:passport-google:clientSecret': req.body.googleClientSecret,
       'security:passport-google:clientSecret': req.body.googleClientSecret,
       'security:passport-google:isSameUsernameTreatedAsIdenticalUser': req.body.isSameUsernameTreatedAsIdenticalUser,
       'security:passport-google:isSameUsernameTreatedAsIdenticalUser': req.body.isSameUsernameTreatedAsIdenticalUser,