Basic functionality in place, need improved errors and logged in redirect

This commit is contained in:
Tom Moor
2018-11-03 20:27:57 -07:00
parent 07e61bd347
commit 21b1c0747c
24 changed files with 512 additions and 130 deletions

View File

@@ -2,6 +2,7 @@
import crypto from 'crypto';
import Router from 'koa-router';
import addMonths from 'date-fns/add_months';
import { stripSubdomain } from '../utils/domains';
import { capitalize } from 'lodash';
import { OAuth2Client } from 'google-auth-library';
import { User, Team } from '../models';
@@ -100,13 +101,15 @@ router.get('google.callback', async ctx => {
ctx.cookies.set('lastSignedIn', 'google', {
httpOnly: false,
expires: new Date('2100'),
domain: stripSubdomain(ctx.request.hostname),
});
ctx.cookies.set('accessToken', user.getJwtToken(), {
httpOnly: false,
expires: addMonths(new Date(), 1),
domain: stripSubdomain(ctx.request.hostname),
});
ctx.redirect('/');
ctx.redirect(team.url);
});
export default router;