|
@@ -53,6 +53,15 @@ module.exports = (crowi) => {
|
|
|
return configManager.updateConfigsInTheSameNamespace('crowi', params, true);
|
|
return configManager.updateConfigsInTheSameNamespace('crowi', params, true);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ function generateAccessToken() {
|
|
|
|
|
+ const hasher = crypto.createHash('sha256');
|
|
|
|
|
+ hasher.update(`${new Date().getTime()}`);
|
|
|
|
|
+
|
|
|
|
|
+ return hasher.digest('base64');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* @swagger
|
|
* @swagger
|
|
|
*
|
|
*
|
|
@@ -136,5 +145,33 @@ module.exports = (crowi) => {
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @swagger
|
|
|
|
|
+ *
|
|
|
|
|
+ * /slack-integration/access-token:
|
|
|
|
|
+ * put:
|
|
|
|
|
+ * tags: [SlackIntegration]
|
|
|
|
|
+ * operationId: getCustomBotSetting
|
|
|
|
|
+ * summary: /slack-integration
|
|
|
|
|
+ * description: Generate accessToken
|
|
|
|
|
+ * responses:
|
|
|
|
|
+ * 200:
|
|
|
|
|
+ * description: Succeeded to get SigningSecret, SlackBotToken and BotType.
|
|
|
|
|
+ */
|
|
|
|
|
+ router.put('/access-token', loginRequiredStrictly, adminRequired, csrf, async(req, res) => {
|
|
|
|
|
+
|
|
|
|
|
+ try {
|
|
|
|
|
+ const accessToken = generateAccessToken();
|
|
|
|
|
+ await updateSlackBotSettings({ 'slackbot:access-token': accessToken });
|
|
|
|
|
+
|
|
|
|
|
+ return res.apiv3({ accessToken });
|
|
|
|
|
+ }
|
|
|
|
|
+ catch (error) {
|
|
|
|
|
+ const msg = 'Error occured in updating Custom bot setting';
|
|
|
|
|
+ logger.error('Error', error);
|
|
|
|
|
+ return res.apiv3Err(new ErrorV3(msg, 'update-CustomBotSetting-failed'));
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+
|
|
|
return router;
|
|
return router;
|
|
|
};
|
|
};
|