Skip to content

Commit

Permalink
Merge pull request #453 from crowi/fix/slack-settings
Browse files Browse the repository at this point in the history
Fix app crash when opening notification settings page after installed
  • Loading branch information
sotarok committed Jun 13, 2019
2 parents 5c8e4b5 + 9e9ef70 commit f3e87da
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/routes/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,14 @@ module.exports = function(crowi, app) {
actions.notification.index = function(req, res) {
const config = crowi.getConfig()
const UpdatePost = crowi.model('UpdatePost')
let slackSetting = config.notification || {}
const hasSlackConfig = Config.hasSlackConfig(config)
const hasSlackToken = Config.hasSlackToken(config)
const slack = crowi.slack
let slackAuthUrl = ''
const appUrl = config.crowi['app:url']

if (!Config.hasSlackConfig(config)) {
slackSetting['slack:clientId'] = ''
slackSetting['slack:clientSecret'] = ''
} else {
slackAuthUrl = slack.getAuthorizeURL()
}
const defaultSlackSetting = { 'slack:clientId': '', 'slack:clientSecret': '' }
let slackSetting = hasSlackConfig ? config.notification : defaultSlackSetting
const slackAuthUrl = hasSlackConfig ? slack.getAuthorizeURL() : ''

if (req.session.slackSetting) {
slackSetting = req.session.slackSetting
Expand All @@ -135,7 +130,7 @@ module.exports = function(crowi, app) {

req.session.slackSetting = slackSetting
if (req.form.isValid) {
Config.updateConfigByNamespace('notification', slackSetting)
await Config.updateConfigByNamespace('notification', slackSetting)
req.session.slackSetting = null

await crowi.setupSlack()
Expand Down

0 comments on commit f3e87da

Please sign in to comment.