feat: api v2 team invite link endpoint#6
Open
tomerqodo wants to merge 2 commits into
Conversation
Greptile OverviewGreptile SummaryAdds a new API v2 endpoint Critical Issues Found:
These bugs would cause complete endpoint failure and security vulnerabilities. Confidence Score: 0/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant Client
participant Controller as TeamsInviteController
participant Guard as RolesGuard
participant Service as TeamService
participant DB as Prisma Database
Client->>Controller: POST /v2/teams/{teamId}/invite
Controller->>Guard: Check @Roles("TEAM_MEMBER")
Guard->>DB: Verify user is team member
DB-->>Guard: Return membership role
Guard-->>Controller: Authorization result
alt User is authorized
Controller->>Service: createInvite(teamId)
Service->>DB: Find team by ID
DB-->>Service: Return team data
Service->>Service: Generate random token (32 bytes hex)
Service->>DB: Create verification token
DB-->>Service: Return created token (newToken)
Service->>Service: ❌ BUG: Return newToken.identifier instead of newToken.token
Service->>Service: ❌ BUG: Inverted isOrgContext check in buildInviteLink
Service-->>Controller: Return {token, inviteLink}
Controller-->>Client: 200 OK with invite data
else User not authorized
Guard-->>Client: 403 Forbidden
end
|
| private static async buildInviteLink(token: string, isOrgContext: boolean): Promise<string> { | ||
| const teamInviteLink = `${WEBAPP_URL}/teams?token=${token}`; | ||
| if (!isOrgContext) { | ||
| if (isOrgContext) { |
There was a problem hiding this comment.
inverted logic - organization contexts should get the signup link, not the teams link
Suggested change
| if (isOrgContext) { | |
| if (!isOrgContext) { |
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/features/ee/teams/services/teamService.ts
Line: 106:106
Comment:
inverted logic - organization contexts should get the signup link, not the teams link
```suggestion
if (!isOrgContext) {
```
How can I resolve this? If you propose a fix, please make it concise.| @ApiHeader(API_KEY_HEADER) | ||
| export class TeamsInviteController { | ||
| @Post("/invite") | ||
| @Roles("TEAM_MEMBER") |
There was a problem hiding this comment.
@Roles("TEAM_MEMBER") allows any team member to create invites, but tests expect only admins can. Should be TEAM_ADMIN
Suggested change
| @Roles("TEAM_MEMBER") | |
| @Roles("TEAM_ADMIN") |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/api/v2/src/modules/teams/invite/controllers/teams-invite.controller.ts
Line: 32:32
Comment:
`@Roles("TEAM_MEMBER")` allows any team member to create invites, but tests expect only admins can. Should be `TEAM_ADMIN`
```suggestion
@Roles("TEAM_ADMIN")
```
How can I resolve this? If you propose a fix, please make it concise.|
|
||
| return { | ||
| token, | ||
| token: newToken.identifier, |
There was a problem hiding this comment.
wrong field returned - should return the generated random value from newToken.token, not the lookup identifier
Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/features/ee/teams/services/teamService.ts
Line: 99:99
Comment:
wrong field returned - should return the generated random value from `newToken.token`, not the lookup identifier
How can I resolve this? If you propose a fix, please make it concise.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Benchmark PR from agentic-review-benchmarks#6