|
|
@@ -132,22 +132,23 @@ module.exports = function(crowi, app) {
|
|
|
var config = crowi.getConfig();
|
|
|
var UpdatePost = crowi.model('UpdatePost');
|
|
|
var slackSetting = Config.setupCofigFormData('notification', config);
|
|
|
- var hasSlackConfig = Config.hasSlackConfig(config);
|
|
|
+ var hasSlackAppConfig = Config.hasSlackAppConfig(config);
|
|
|
var hasSlackIwhUrl = Config.hasSlackIwhUrl(config);
|
|
|
var hasSlackToken = Config.hasSlackToken(config);
|
|
|
var slack = crowi.slack;
|
|
|
var slackAuthUrl = '';
|
|
|
|
|
|
- if (!Config.hasSlackConfig(req.config)) {
|
|
|
+ if (!Config.hasSlackAppConfig(req.config)) {
|
|
|
slackSetting['slack:clientId'] = '';
|
|
|
slackSetting['slack:clientSecret'] = '';
|
|
|
}
|
|
|
+ else {
|
|
|
+ slackAuthUrl = slack.getAuthorizeURL();
|
|
|
+ }
|
|
|
if (!Config.hasSlackIwhUrl(req.config)) {
|
|
|
slackSetting['slack:incomingWebhookUrl'] = '';
|
|
|
}
|
|
|
|
|
|
- slackAuthUrl = slack.getAuthorizeURL();
|
|
|
-
|
|
|
if (req.session.slackSetting) {
|
|
|
slackSetting = req.session.slackSetting;
|
|
|
req.session.slackSetting = null;
|
|
|
@@ -158,7 +159,7 @@ module.exports = function(crowi, app) {
|
|
|
return res.render('admin/notification', {
|
|
|
settings,
|
|
|
slackSetting,
|
|
|
- hasSlackConfig,
|
|
|
+ hasSlackAppConfig,
|
|
|
hasSlackIwhUrl,
|
|
|
hasSlackToken,
|
|
|
slackAuthUrl
|
|
|
@@ -177,6 +178,7 @@ module.exports = function(crowi, app) {
|
|
|
req.flash('successMessage', ['Successfully Updated!']);
|
|
|
req.session.slackSetting = null;
|
|
|
|
|
|
+ // Re-setup
|
|
|
crowi.setupSlack().then(function() {
|
|
|
return res.redirect('/admin/notification');
|
|
|
});
|
|
|
@@ -192,7 +194,7 @@ module.exports = function(crowi, app) {
|
|
|
var code = req.query.code;
|
|
|
var config = crowi.getConfig();
|
|
|
|
|
|
- if (!code || !Config.hasSlackConfig(req.config)) {
|
|
|
+ if (!code || !Config.hasSlackAppConfig(req.config)) {
|
|
|
return res.redirect('/admin/notification');
|
|
|
}
|
|
|
|
|
|
@@ -257,6 +259,8 @@ module.exports = function(crowi, app) {
|
|
|
Config.updateNamespaceByArray('notification', slackIwhSetting, function(err, config) {
|
|
|
Config.updateConfigCache('notification', config);
|
|
|
req.flash('successMessage', ['Successfully Updated!']);
|
|
|
+
|
|
|
+ // Re-setup
|
|
|
crowi.setupSlack().then(function() {
|
|
|
return res.redirect('/admin/notification#slack-incoming-webhooks');
|
|
|
});
|