* fix: Don't set cookie domain when not using multiple subdomains * wip logging domain * wip logging domain * wip logging domain * wip logging domain * Revert "wip logging domain" This reverts commit 325907e74962179e02cee0b1df364a3aedbe62e3. * Revert "wip logging domain" This reverts commit 6ee095a49e9c18999a20d5379234323d49d5e6c8. * Revert "wip logging domain" This reverts commit 813d8eb960cdf4dd6db4795739df3adf895600e2. * Revert "wip logging domain" This reverts commit f1ca81927626bbd0d46c1963510d115a003176d8. * Remove SUBDOMAINS_ENABLED from documented env variables, no-one self hosting should need this – it just adds confusion to those looking to host on a single subdomain fix: Account for server/client process.env parsing Co-authored-by: Nan Yu <nanyu@Nans-MBP-2.lan> Co-authored-by: Nan Yu <nan@getoutline.com>
45 lines
1.1 KiB
JavaScript
45 lines
1.1 KiB
JavaScript
// @flow
|
|
import bodyParser from 'koa-bodyparser';
|
|
import Koa from 'koa';
|
|
import Router from 'koa-router';
|
|
import validation from '../middlewares/validation';
|
|
import auth from '../middlewares/authentication';
|
|
import addMonths from 'date-fns/add_months';
|
|
import { Team } from '../models';
|
|
import { getCookieDomain } from '../../shared/utils/domains';
|
|
|
|
import slack from './slack';
|
|
import google from './google';
|
|
import email from './email';
|
|
|
|
const app = new Koa();
|
|
const router = new Router();
|
|
|
|
router.use('/', slack.routes());
|
|
router.use('/', google.routes());
|
|
router.use('/', email.routes());
|
|
|
|
router.get('/redirect', auth(), async ctx => {
|
|
const user = ctx.state.user;
|
|
|
|
// transfer access token cookie from root to subdomain
|
|
ctx.cookies.set('accessToken', undefined, {
|
|
httpOnly: true,
|
|
domain: getCookieDomain(ctx.request.hostname),
|
|
});
|
|
|
|
ctx.cookies.set('accessToken', user.getJwtToken(), {
|
|
httpOnly: false,
|
|
expires: addMonths(new Date(), 3),
|
|
});
|
|
|
|
const team = await Team.findByPk(user.teamId);
|
|
ctx.redirect(`${team.url}/home`);
|
|
});
|
|
|
|
app.use(bodyParser());
|
|
app.use(validation());
|
|
app.use(router.routes());
|
|
|
|
export default app;
|