Move auth to router.use

This commit is contained in:
Jori Lallo
2017-12-26 15:01:16 +02:00
parent 4406ec8e15
commit a74e90fc09
4 changed files with 13 additions and 8 deletions

View File

@ -7,12 +7,13 @@ import auth from './middlewares/authentication';
import { presentUser } from '../presenters';
const router = new Router();
router.use(auth());
router.post('user.info', auth(), async ctx => {
router.post('user.info', async ctx => {
ctx.body = { data: await presentUser(ctx, ctx.state.user) };
});
router.post('user.update', auth(), async ctx => {
router.post('user.update', async ctx => {
const { user } = ctx.state;
const { name, avatarUrl } = ctx.body;
const endpoint = publicS3Endpoint();
@ -28,7 +29,7 @@ router.post('user.update', auth(), async ctx => {
ctx.body = { data: await presentUser(ctx, user) };
});
router.post('user.s3Upload', auth(), async ctx => {
router.post('user.s3Upload', async ctx => {
const { filename, kind, size } = ctx.body;
ctx.assertPresent(filename, 'filename is required');
ctx.assertPresent(kind, 'kind is required');