Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
3f2680671b
|
|||
|
fd06e17d7d
|
|||
|
efdea10b14
|
@@ -17,7 +17,7 @@ class PermissionMiddleware extends Middleware {
|
|||||||
req,
|
req,
|
||||||
reason,
|
reason,
|
||||||
check,
|
check,
|
||||||
oauth_client_id: req.oauth.client.id,
|
oauth_client_id: req.oauth.client.uuid,
|
||||||
})
|
})
|
||||||
|
|
||||||
return res.status(401)
|
return res.status(401)
|
||||||
|
|||||||
@@ -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
|
||||||
|
|||||||
Reference in New Issue
Block a user