fix: cleaning deprecated resolvers on Team Module (HBE-157) (#25)
* fix: retrive user object from gql-team-member-guard * feat: removed addTeamMemberByEmail resolver
This commit is contained in:
@@ -27,8 +27,9 @@ export class GqlTeamMemberGuard implements CanActivate {
|
|||||||
if (!requireRoles) throw new Error(BUG_TEAM_NO_REQUIRE_TEAM_ROLE);
|
if (!requireRoles) throw new Error(BUG_TEAM_NO_REQUIRE_TEAM_ROLE);
|
||||||
|
|
||||||
const gqlExecCtx = GqlExecutionContext.create(context);
|
const gqlExecCtx = GqlExecutionContext.create(context);
|
||||||
|
const { req, headers } = gqlExecCtx.getContext();
|
||||||
|
const user = headers ? headers.user : req.user;
|
||||||
|
|
||||||
const { user } = gqlExecCtx.getContext().req;
|
|
||||||
if (user == undefined) throw new Error(BUG_AUTH_NO_USER_CTX);
|
if (user == undefined) throw new Error(BUG_AUTH_NO_USER_CTX);
|
||||||
|
|
||||||
const { teamID } = gqlExecCtx.getArgs<{ teamID: string }>();
|
const { teamID } = gqlExecCtx.getArgs<{ teamID: string }>();
|
||||||
|
|||||||
@@ -226,41 +226,6 @@ export class TeamResolver {
|
|||||||
return isDeleted.right;
|
return isDeleted.right;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Mutation(() => TeamMember, {
|
|
||||||
description: 'Adds a team member to the team via email',
|
|
||||||
deprecationReason:
|
|
||||||
'This is only present for backwards compatibility and will be removed soon use team invitations instead',
|
|
||||||
})
|
|
||||||
@RequiresTeamRole(TeamMemberRole.OWNER)
|
|
||||||
@UseGuards(GqlAuthGuard, GqlTeamMemberGuard)
|
|
||||||
async addTeamMemberByEmail(
|
|
||||||
@Args({
|
|
||||||
name: 'teamID',
|
|
||||||
description: 'ID of the team to add to',
|
|
||||||
type: () => ID,
|
|
||||||
})
|
|
||||||
teamID: string,
|
|
||||||
@Args({
|
|
||||||
name: 'userEmail',
|
|
||||||
description: 'Email of the user to add to team',
|
|
||||||
})
|
|
||||||
userEmail: string,
|
|
||||||
@Args({
|
|
||||||
name: 'userRole',
|
|
||||||
description: 'The role of the user to add in the team',
|
|
||||||
type: () => TeamMemberRole,
|
|
||||||
})
|
|
||||||
role: TeamMemberRole,
|
|
||||||
): Promise<TeamMember> {
|
|
||||||
const teamMember = await this.teamService.addMemberToTeamWithEmail(
|
|
||||||
teamID,
|
|
||||||
userEmail,
|
|
||||||
role,
|
|
||||||
);
|
|
||||||
if (E.isLeft(teamMember)) throwErr(teamMember.left);
|
|
||||||
return teamMember.right;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Mutation(() => TeamMember, {
|
@Mutation(() => TeamMember, {
|
||||||
description: 'Update role of a team member the executing user owns',
|
description: 'Update role of a team member the executing user owns',
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user