mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
Merge pull request #6729 from overleaf/jpa-cleanup-staff-access
[web] admin privilege does not imply staffAccess GitOrigin-RevId: 89760c7a9a8f0b0c82ebee40ca3236e9894ab9fa
This commit is contained in:
parent
d59b154f07
commit
c881829e04
3 changed files with 1 additions and 9 deletions
|
@ -1,14 +1,10 @@
|
|||
const { UserSchema } = require('../../models/User')
|
||||
const { hasAdminAccess } = require('./AdminAuthorizationHelper')
|
||||
|
||||
module.exports = {
|
||||
hasAnyStaffAccess,
|
||||
}
|
||||
|
||||
function hasAnyStaffAccess(user) {
|
||||
if (hasAdminAccess(user)) {
|
||||
return true
|
||||
}
|
||||
if (!user.staffAccess) {
|
||||
return false
|
||||
}
|
||||
|
|
|
@ -1,13 +1,9 @@
|
|||
const { hasAdminAccess } = require('../Helpers/AdminAuthorizationHelper')
|
||||
const UserMembershipAuthorization = {
|
||||
hasStaffAccess(requiredStaffAccess) {
|
||||
return req => {
|
||||
if (!req.user) {
|
||||
return false
|
||||
}
|
||||
if (hasAdminAccess(req.user)) {
|
||||
return true
|
||||
}
|
||||
return (
|
||||
requiredStaffAccess &&
|
||||
req.user.staffAccess &&
|
||||
|
|
|
@ -43,7 +43,7 @@ describe('AuthorizationHelper', function () {
|
|||
it('with admin user', function () {
|
||||
const user = { isAdmin: true }
|
||||
this.AdminAuthorizationHelper.hasAdminAccess.returns(true)
|
||||
expect(this.AuthorizationHelper.hasAnyStaffAccess(user)).to.be.true
|
||||
expect(this.AuthorizationHelper.hasAnyStaffAccess(user)).to.be.false
|
||||
})
|
||||
|
||||
it('with staff user', function () {
|
||||
|
|
Loading…
Reference in a new issue