Working direct install flow

This commit is contained in:
Tom Moor
2017-11-21 23:51:31 -08:00
parent 13623cb1b3
commit dd2cd2f9d8
7 changed files with 63 additions and 64 deletions

View File

@ -8,6 +8,7 @@ import sendfile from 'koa-sendfile';
import serve from 'koa-static';
import subdomainRedirect from './middlewares/subdomainRedirect';
import renderpage from './utils/renderpage';
import { slackAuth } from '../shared/utils/routeHelpers';
import Home from './pages/Home';
import About from './pages/About';
@ -44,6 +45,19 @@ if (process.env.NODE_ENV === 'production') {
});
}
// slack direct install
router.get('/auth/slack/install', async ctx => {
const state = Math.random()
.toString(36)
.substring(7);
ctx.cookies.set('state', state, {
httpOnly: false,
expires: new Date('2100'),
});
ctx.redirect(slackAuth(state));
});
// static pages
router.get('/about', ctx => renderpage(ctx, <About />));
router.get('/pricing', ctx => renderpage(ctx, <Pricing />));