Request auth on first load with existing token
This commit is contained in:
@ -1,11 +1,24 @@
|
||||
// @flow
|
||||
import Router from 'koa-router';
|
||||
import auth from './middlewares/authentication';
|
||||
import { presentUser, presentTeam } from '../presenters';
|
||||
import { User, Team } from '../models';
|
||||
import * as Slack from '../slack';
|
||||
|
||||
const router = new Router();
|
||||
|
||||
router.post('auth.info', auth(), async ctx => {
|
||||
const user = ctx.state.user;
|
||||
const team = await Team.findOne({ where: { id: user.teamId } });
|
||||
|
||||
ctx.body = {
|
||||
data: {
|
||||
user: await presentUser(ctx, user),
|
||||
team: await presentTeam(ctx, team),
|
||||
},
|
||||
};
|
||||
});
|
||||
|
||||
router.post('auth.slack', async ctx => {
|
||||
const { code } = ctx.body;
|
||||
ctx.assertPresent(code, 'code is required');
|
||||
|
Reference in New Issue
Block a user