refactor: refactoring Team-Collections with reordering in self-host (HBE-150) (#34)
* chore: removed firebase module as a dependency from team-collection module * chore: modified team-collection resolver file to use input-args types * chore: modified getTeamOfCollection service method and resolver * chore: modified getParentOfCollection service method in team-collection module * chore: modified getChildrenOfCollection service method in team-collection module * chore: added new fields to TeamCollection model in prisma schema file * chore: modified getCollection service method and resolver in team-collection module * chore: modified createCollection service method and resolver in team-collection module * chore: created cast helper function to resolve issue with creation mutation in team-collection * chore: modified teamCollectionRemoved subscription return types * chore: removed return types from subscriptions in team-collection module * chore: removed all instances of getTeamCollections service method in team-collection module * feat: added mutation to handle moving collections and supporting subscriptions * feat: added mutation to re-ordering team-collection order * chore: added teacher comments to both collection modules * test: added test cases for getTeamOfCollection service method * test: added test cases for getParentOfCollection service method * test: added test cases for getChildrenOfCollection service method * test: added test cases for getTeamRootCollections service method * test: added test cases for getCollection service method * test: added test cases for createCollection service method * chore: renamed renameCollection to renameUserCollection in UserCollection module * test: added test cases for renameCollection service method * test: added test cases for deleteCollection service method * test: added test cases for moveCollection service method * test: added test cases for updateCollectionOrder service method * chore: added import and export to JSON mutations to team-collection module * chore: created replaceCollectionsWithJSON mutation in team-collection module * chore: moved the mutation and service method of importCollectionFromFirestore to the end of file * chore: added helper comments to all import,export functions * chore: exportCollectionsToJSON service method orders collections and requests in ascending order * chore: added test cases for importCollectionsFromJSON service method * chore: added ToDo to write test cases for exportCollectionsToJSON * chore: removed prisma migration folder * chore: completed all changes requested in inital PR review * chore: completed all changes requested in second PR review * chore: completed all changes requested in third PR review
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
TEAM_INVALID_COLL_ID,
|
||||
TEAM_REQ_NOT_MEMBER,
|
||||
} from 'src/errors';
|
||||
import * as E from 'fp-ts/Either';
|
||||
|
||||
@Injectable()
|
||||
export class GqlCollectionTeamMemberGuard implements CanActivate {
|
||||
@@ -29,6 +30,7 @@ export class GqlCollectionTeamMemberGuard implements CanActivate {
|
||||
if (!requireRoles) throw new Error(BUG_TEAM_NO_REQUIRE_TEAM_ROLE);
|
||||
|
||||
const gqlExecCtx = GqlExecutionContext.create(context);
|
||||
|
||||
const { user } = gqlExecCtx.getContext().req;
|
||||
if (user == undefined) throw new Error(BUG_AUTH_NO_USER_CTX);
|
||||
|
||||
@@ -38,10 +40,10 @@ export class GqlCollectionTeamMemberGuard implements CanActivate {
|
||||
const collection = await this.teamCollectionService.getCollection(
|
||||
collectionID,
|
||||
);
|
||||
if (!collection) throw new Error(TEAM_INVALID_COLL_ID);
|
||||
if (E.isLeft(collection)) throw new Error(TEAM_INVALID_COLL_ID);
|
||||
|
||||
const member = await this.teamService.getTeamMember(
|
||||
collection.teamID,
|
||||
collection.right.teamID,
|
||||
user.uid,
|
||||
);
|
||||
if (!member) throw new Error(TEAM_REQ_NOT_MEMBER);
|
||||
|
||||
Reference in New Issue
Block a user