mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #2025 from overleaf/ta-metrics-admin
Admin Metrics GitOrigin-RevId: 1179893b9b2148110b86caca12b057fccb04f3af
This commit is contained in:
parent
67b68b0171
commit
7d1bab4e88
4 changed files with 29 additions and 2 deletions
|
@ -122,6 +122,18 @@ module.exports = UserMembershipAuthorization = {
|
|||
)
|
||||
},
|
||||
|
||||
requireAdminMetricsStaffAccess(req, res, next) {
|
||||
return requireAccessToEntity(
|
||||
'admin',
|
||||
'admin',
|
||||
req,
|
||||
res,
|
||||
next,
|
||||
'adminMetrics',
|
||||
true
|
||||
)
|
||||
},
|
||||
|
||||
requireTemplateMetricsAccess(req, res, next) {
|
||||
const templateId = req.params.id
|
||||
return request(
|
||||
|
@ -202,6 +214,12 @@ module.exports = UserMembershipAuthorization = {
|
|||
res,
|
||||
next
|
||||
)
|
||||
} else if (req.query.resource_type === 'admin') {
|
||||
return UserMembershipAuthorization.requireAdminMetricsStaffAccess(
|
||||
req,
|
||||
res,
|
||||
next
|
||||
)
|
||||
}
|
||||
return requireAccessToEntity(
|
||||
req.query.resource_type,
|
||||
|
@ -294,6 +312,9 @@ var getEntity = function(
|
|||
if (!entityConfig) {
|
||||
return callback(new Errors.NotFoundError(`No such entity: ${entityName}`))
|
||||
}
|
||||
if (!entityConfig.modelName) {
|
||||
return callback(null, { id: entityName }, entityConfig, true)
|
||||
}
|
||||
|
||||
return UserMembershipHandler.getEntity(
|
||||
entityId,
|
||||
|
|
|
@ -127,5 +127,10 @@ module.exports = {
|
|||
primaryKey: 'slug',
|
||||
access: 'managerIds'
|
||||
}
|
||||
},
|
||||
|
||||
admin: {
|
||||
// for metrics only
|
||||
modelName: null
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ module.exports = UserMembershipsHandler = {
|
|||
const entityConfigs = []
|
||||
for (let key in UserMembershipEntityConfigs) {
|
||||
const entityConfig = UserMembershipEntityConfigs[key]
|
||||
if (entityConfig.fields.write != null) {
|
||||
if (entityConfig.fields && entityConfig.fields.write != null) {
|
||||
entityConfigs.push(entityConfig)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -42,7 +42,8 @@ const UserSchema = new Schema({
|
|||
institutionMetrics: { type: Boolean, default: false },
|
||||
institutionManagement: { type: Boolean, default: false },
|
||||
groupMetrics: { type: Boolean, default: false },
|
||||
groupManagement: { type: Boolean, default: false }
|
||||
groupManagement: { type: Boolean, default: false },
|
||||
adminMetrics: { type: Boolean, default: false }
|
||||
},
|
||||
signUpDate: {
|
||||
type: Date,
|
||||
|
|
Loading…
Reference in a new issue