-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix permissions for member and profile API calls
- Loading branch information
Showing
8 changed files
with
101 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
const { isPublic, isMember } = require('../../lib/team') | ||
|
||
/** | ||
* team:view-members | ||
* | ||
* To view a team's members, the team needs to be either public | ||
* or the user should be a member of the team | ||
* | ||
* @param {string} uid user id | ||
* @param {Object} params request parameters | ||
* @returns {boolean} can the request go through? | ||
*/ | ||
async function viewTeamMembers (uid, { id }) { | ||
const publicTeam = await isPublic(id) | ||
if (publicTeam) return publicTeam | ||
|
||
try { | ||
return await isMember(id, uid) | ||
} catch (e) { | ||
return false | ||
} | ||
} | ||
|
||
module.exports = viewTeamMembers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,14 @@ | ||
const { isPublic, isMember } = require('../../lib/team') | ||
|
||
/** | ||
* team:view | ||
* | ||
* To view a team, the team needs to be either public | ||
* or the user should be a member of the team | ||
* This covers team metadata, this should always be available | ||
* to any users. Permission for individual pieces of metadata are controlled within | ||
* the route code. | ||
* | ||
* @param {string} uid user id | ||
* @param {Object} params request parameters | ||
* @returns {boolean} can the request go through? | ||
*/ | ||
async function viewTeam (uid, { id }) { | ||
const publicTeam = await isPublic(id) | ||
if (publicTeam) return publicTeam | ||
|
||
try { | ||
return await isMember(id, uid) | ||
} catch (e) { | ||
return false | ||
} | ||
async function viewTeam () { | ||
return true | ||
} | ||
|
||
module.exports = viewTeam |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters