2 Commits
ci=02 ... ci-04

Author SHA1 Message Date
fd06e17d7d Use req.user to check auth instead of req.is_auth
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-10-18 18:35:55 -05:00
efdea10b14 Guarantee req.oauth in APIRoute middleware
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2020-10-18 17:19:26 -05:00

View File

@@ -7,9 +7,10 @@ class APIRouteMiddleware extends Middleware {
async test(req, res, next, { allow_token = true, allow_user = true }) { async test(req, res, next, { allow_token = true, allow_user = true }) {
// First, check if there is a user in the session. // First, check if there is a user in the session.
if ( allow_user && req.is_auth ) { if ( allow_user && req.user ) {
return next() return next()
} else if ( allow_token ) { } else if ( allow_token ) {
if ( !req.oauth ) req.oauth = {}
return req.app.oauth2.authorise()(req, res, async e => { return req.app.oauth2.authorise()(req, res, async e => {
if ( e ) return next(e) if ( e ) return next(e)
// Look up the OAuth2 client an inject it into the route // Look up the OAuth2 client an inject it into the route