Attach current user to context.user

This commit is contained in:
Adrian Obelmejias
2016-08-30 17:10:56 -04:00
parent de550f31df
commit e95c2cedd3
+2 -2
View File
@@ -17,8 +17,8 @@ export async function ensureUser (ctx, next) {
ctx.throw(401)
}
const user = await User.findById(decoded.id, '-password')
if (!user) {
ctx.state.user = await User.findById(decoded.id, '-password')
if (!ctx.state.user) {
ctx.throw(401)
}