This repository was archived by the owner on Apr 13, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed
Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -437,6 +437,15 @@ GameSchema.methods.hasPermission = function(token, callback) {
437437 } ) ;
438438 } )
439439 . then ( function ( groups ) {
440+ // first, check if the user is an admin (by looking at their user group). If so, they should have permissions on
441+ // all games
442+ for ( let i = 0 ; i < groups . length ; i ++ ) {
443+ if ( groups [ i ] . isUserGroup === true && groups [ i ] . privilege === 2 ) {
444+ callback ( null , game ) ;
445+ return ;
446+ }
447+ }
448+
440449 const ids = groups . map ( group => group . _id . toString ( ) ) ;
441450 const gameGroups = game . groups . map ( entry => {
442451 if ( entry . group . _id ) {
Original file line number Diff line number Diff line change @@ -106,5 +106,32 @@ describe('api/release', () => {
106106 . send ( releaseParams ) ;
107107 expect ( postResponse . body . success ) . to . equal ( false ) ;
108108 } ) ;
109+
110+ it ( 'should still allow an admin user to create a game, even if they do not have privileges on that game' , async function ( ) {
111+ await dataMakers . makeGame ( 'prod' ) ;
112+ let gameResponse = await request . get ( 'http://localhost:3000/api/games' ) ;
113+
114+ // make a admin level access token
115+ let editor = await dataMakers . makeUser ( 2 ) ;
116+ let token = await dataMakers . getUserToken ( editor ) ;
117+ // get the game slug from the api response
118+ let gameSlug = gameResponse . body . data [ 0 ] . slug ;
119+
120+ // make a new commit id for the new release
121+ let commitId = dataMakers . makeRandomString ( 40 ) ;
122+
123+ // send the request
124+ let releaseParams = {
125+ status : 'dev' ,
126+ commitId : commitId ,
127+ version : '1.0.0' ,
128+ token : token
129+ } ;
130+
131+ let postResponse = await request
132+ . post ( `http://localhost:3000/api/release/${ gameSlug } ` )
133+ . send ( releaseParams ) ;
134+ expect ( postResponse . body . success ) . to . equal ( true ) ;
135+ } ) ;
109136 } ) ;
110137} ) ;
You can’t perform that action at this time.
0 commit comments