mirror of
https://github.com/overleaf/overleaf.git
synced 2025-04-20 03:53:45 +00:00
Merge pull request #1062 from sharelatex/ta-metric-authorization
Use UserMembership Authorization Middlewear for Metrics GitOrigin-RevId: a145527723539696c2659baa16c507ab54f629a3
This commit is contained in:
parent
edd832b1f2
commit
aff47a4b11
2 changed files with 10 additions and 2 deletions
|
@ -6,13 +6,13 @@ Errors = require('../Errors/Errors')
|
|||
logger = require("logger-sharelatex")
|
||||
|
||||
module.exports =
|
||||
requireEntityAccess: (entityName) ->
|
||||
requireEntityAccess: (entityName, entityId = null) ->
|
||||
(req, res, next) ->
|
||||
loggedInUser = AuthenticationController.getSessionUser(req)
|
||||
unless loggedInUser
|
||||
return AuthorizationMiddlewear.redirectToRestricted req, res, next
|
||||
|
||||
entityId = req.params.id
|
||||
entityId = req.params.id unless entityId?
|
||||
getEntity entityName, entityId, loggedInUser, (error, entity, entityConfig) ->
|
||||
return next(error) if error?
|
||||
unless entity?
|
||||
|
|
|
@ -19,6 +19,14 @@ module.exports =
|
|||
removeInvite: '/subscription/invites'
|
||||
exportMembers: '/subscription/group/export'
|
||||
|
||||
team: # for metrics only
|
||||
modelName: 'Subscription'
|
||||
fields:
|
||||
primaryKey: 'overleaf.id'
|
||||
access: 'manager_ids'
|
||||
baseQuery:
|
||||
groupPlan: true
|
||||
|
||||
groupManagers:
|
||||
modelName: 'Subscription'
|
||||
fields:
|
||||
|
|
Loading…
Add table
Reference in a new issue