Просмотр исходного кода

Merge branch 'feat/growi-bot' into fix/behavior-when-clicked-reset-button

zahmis 4 лет назад
Родитель
Сommit
a6c3502c0b

+ 1 - 1
packages/slackbot-proxy/src/Server.ts

@@ -75,7 +75,7 @@ export class Server {
   @Inject()
   @Inject()
   injector: InjectorService;
   injector: InjectorService;
 
 
-  $onInit(): Promise<any> | void {
+  $beforeInit(): Promise<any> | void {
     const serverUri = process.env.SERVER_URI;
     const serverUri = process.env.SERVER_URI;
 
 
     if (serverUri === undefined) {
     if (serverUri === undefined) {

+ 1 - 0
src/client/js/components/Admin/SlackIntegration/CustomBotWithProxySettings.jsx

@@ -97,6 +97,7 @@ const CustomBotWithProxySettings = (props) => {
         </div>
         </div>
       </div>
       </div>
       <DeleteSlackBotSettingsModal
       <DeleteSlackBotSettingsModal
+        isResetAll={false}
         isOpen={isDeleteConfirmModalShown}
         isOpen={isDeleteConfirmModalShown}
         onClose={() => setIsDeleteConfirmModalShown(false)}
         onClose={() => setIsDeleteConfirmModalShown(false)}
         onClickDeleteButton={deleteSlackSettingsHandler}
         onClickDeleteButton={deleteSlackSettingsHandler}

+ 1 - 0
src/client/js/components/Admin/SlackIntegration/CustomBotWithoutProxySettings.jsx

@@ -54,6 +54,7 @@ const CustomBotWithoutProxySettings = (props) => {
         />
         />
       </div>
       </div>
       <DeleteSlackBotSettingsModal
       <DeleteSlackBotSettingsModal
+        isResetAll={false}
         isOpen={isDeleteConfirmModalShown}
         isOpen={isDeleteConfirmModalShown}
         onClose={() => setIsDeleteConfirmModalShown(false)}
         onClose={() => setIsDeleteConfirmModalShown(false)}
         onClickDeleteButton={resetSettings}
         onClickDeleteButton={resetSettings}

+ 11 - 2
src/client/js/components/Admin/SlackIntegration/DeleteSlackBotSettingsModal.jsx

@@ -36,7 +36,16 @@ const DeleteSlackBotSettingsModal = React.memo((props) => {
       <ModalHeader tag="h4" toggle={closeButtonHandler} className="bg-danger text-light">
       <ModalHeader tag="h4" toggle={closeButtonHandler} className="bg-danger text-light">
         <span>
         <span>
           <i className="icon-fw icon-fire"></i>
           <i className="icon-fw icon-fire"></i>
-          {t('admin:slack_integration.delete_slackbot_settings')}
+          {props.isResetAll && (
+            <>
+              {t('admin:slack_integration.reset_all_settings')}
+            </>
+          )}
+          {!props.isResetAll && (
+            <>
+              {t('admin:slack_integration.delete_slackbot_settings')}
+            </>
+          )}
         </span>
         </span>
       </ModalHeader>
       </ModalHeader>
       <ModalBody>
       <ModalBody>
@@ -56,7 +65,7 @@ const DeleteSlackBotSettingsModal = React.memo((props) => {
 
 
 DeleteSlackBotSettingsModal.propTypes = {
 DeleteSlackBotSettingsModal.propTypes = {
   t: PropTypes.func.isRequired, // i18next
   t: PropTypes.func.isRequired, // i18next
-
+  isResetAll: PropTypes.bool.isRequired,
   isOpen: PropTypes.bool.isRequired,
   isOpen: PropTypes.bool.isRequired,
   onClose: PropTypes.func,
   onClose: PropTypes.func,
   onClickDeleteButton: PropTypes.func,
   onClickDeleteButton: PropTypes.func,

+ 10 - 0
src/client/js/components/Admin/SlackIntegration/SlackIntegration.jsx

@@ -10,6 +10,7 @@ import CustomBotWithoutProxySettings from './CustomBotWithoutProxySettings';
 import CustomBotWithProxySettings from './CustomBotWithProxySettings';
 import CustomBotWithProxySettings from './CustomBotWithProxySettings';
 import ConfirmBotChangeModal from './ConfirmBotChangeModal';
 import ConfirmBotChangeModal from './ConfirmBotChangeModal';
 import BotTypeCard from './BotTypeCard';
 import BotTypeCard from './BotTypeCard';
+import DeleteSlackBotSettingsModal from './DeleteSlackBotSettingsModal';
 
 
 const botTypes = ['officialBot', 'customBotWithoutProxy', 'customBotWithProxy'];
 const botTypes = ['officialBot', 'customBotWithoutProxy', 'customBotWithProxy'];
 
 
@@ -25,6 +26,7 @@ const SlackIntegration = (props) => {
   const [isRegisterSlackCredentials, setIsRegisterSlackCredentials] = useState(false);
   const [isRegisterSlackCredentials, setIsRegisterSlackCredentials] = useState(false);
   const [isSendTestMessage, setIsSendTestMessage] = useState(false);
   const [isSendTestMessage, setIsSendTestMessage] = useState(false);
   const [slackWSNameInWithoutProxy, setSlackWSNameInWithoutProxy] = useState(null);
   const [slackWSNameInWithoutProxy, setSlackWSNameInWithoutProxy] = useState(null);
+  const [isDeleteConfirmModalShown, setIsDeleteConfirmModalShown] = useState(false);
 
 
   const fetchSlackIntegrationData = useCallback(async() => {
   const fetchSlackIntegrationData = useCallback(async() => {
     try {
     try {
@@ -135,6 +137,13 @@ const SlackIntegration = (props) => {
         onCancelClick={cancelBotChangeHandler}
         onCancelClick={cancelBotChangeHandler}
       />
       />
 
 
+      {/* TODO add onClickDeleteButton */}
+      <DeleteSlackBotSettingsModal
+        isResetAll
+        isOpen={isDeleteConfirmModalShown}
+        onClose={() => setIsDeleteConfirmModalShown(false)}
+      />
+
       <div className="selecting-bot-type mb-5">
       <div className="selecting-bot-type mb-5">
         <h2 className="admin-setting-header mb-4">
         <h2 className="admin-setting-header mb-4">
           {t('admin:slack_integration.selecting_bot_types.slack_bot')}
           {t('admin:slack_integration.selecting_bot_types.slack_bot')}
@@ -154,6 +163,7 @@ const SlackIntegration = (props) => {
             <button
             <button
               className="mx-3 btn btn-outline-danger flex-end"
               className="mx-3 btn btn-outline-danger flex-end"
               type="button"
               type="button"
+              onClick={() => setIsDeleteConfirmModalShown(true)}
             >{t('admin:slack_integration.reset_all_settings')}
             >{t('admin:slack_integration.reset_all_settings')}
             </button>
             </button>
           )}
           )}

+ 3 - 3
src/server/models/slack-app-integration.js

@@ -7,11 +7,11 @@ const schema = new mongoose.Schema({
 });
 });
 class SlackAppIntegration {
 class SlackAppIntegration {
 
 
-  static generateAccessToken(user) {
+  static generateAccessToken() {
     const hasher1 = crypto.createHash('sha512');
     const hasher1 = crypto.createHash('sha512');
     const hasher2 = crypto.createHash('sha512');
     const hasher2 = crypto.createHash('sha512');
-    const tokenGtoP = hasher1.update(new Date().getTime() + user._id).digest('base64');
-    const tokenPtoG = hasher2.update(new Date().getTime() + user.username).digest('base64');
+    const tokenGtoP = hasher1.update(`${new Date().getTime().toString()}proxy`).digest('base64');
+    const tokenPtoG = hasher2.update(`${new Date().getTime().toString()}growi`).digest('base64');
     return [tokenGtoP, tokenPtoG];
     return [tokenGtoP, tokenPtoG];
   }
   }