Merge pull request #2306 from overleaf/sk-fix-restricted-users-redux

Hide review panel UI and data for restricted users

GitOrigin-RevId: c2211b71860f2d7e8b54c40a7a89a1dd2e6a5d5a
This commit is contained in:
Shane Kilkelly 2019-10-31 10:21:00 +00:00 committed by sharelatex
parent 4b6f038a82
commit 365bd08425
3 changed files with 30 additions and 1 deletions

View file

@ -1,5 +1,6 @@
let AuthorizationManager
const CollaboratorsGetter = require('../Collaborators/CollaboratorsGetter')
const CollaboratorsHandler = require('../Collaborators/CollaboratorsHandler')
const ProjectGetter = require('../Project/ProjectGetter')
const { User } = require('../../models/User')
const PrivilegeLevels = require('./PrivilegeLevels')
@ -15,6 +16,32 @@ module.exports = AuthorizationManager = {
)
},
isRestrictedUserForProject(userId, projectId, callback) {
this.getPrivilegeLevelForProject(
userId,
projectId,
null,
(err, privilegeLevel) => {
if (err) {
return callback(err)
}
CollaboratorsHandler.userIsTokenMember(
userId,
projectId,
(err, isTokenMember) => {
if (err) {
return callback(err)
}
callback(
null,
this.isRestrictedUser(userId, privilegeLevel, isTokenMember)
)
}
)
}
)
},
getPublicAccessLevel(projectId, callback) {
if (!ObjectId.isValid(projectId)) {
return callback(new Error('invalid project id'))

View file

@ -75,6 +75,7 @@ div.full-size(
line-height="settings.lineHeight || ui.defaultLineHeight"
)
if !isRestrictedTokenMember
include ./review-panel
.ui-layout-east

View file

@ -28,6 +28,7 @@ describe('AuthorizationManager', function() {
},
requires: {
'../Collaborators/CollaboratorsGetter': (this.CollaboratorsGetter = {}),
'../Collaborators/CollaboratorsHandler': (this.CollaboratorsHandler = {}),
'../Project/ProjectGetter': (this.ProjectGetter = {}),
'../../models/User': {
User: (this.User = {})