Move auth to router.use
This commit is contained in:
@ -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');
|
||||
|
Reference in New Issue
Block a user