Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix team creation on the server not automatically adding the current user #266

Merged
merged 6 commits into from
Oct 1, 2024

Conversation

fomalhautb
Copy link
Contributor

@fomalhautb fomalhautb commented Sep 25, 2024

Previously, the server team creation API does not allow adding a specific user as the team creator, so the user.createTeam on the server will not add the current user to the team. Now with this new API endpoint design it is fixed.

Copy link

vercel bot commented Sep 25, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
stack-backend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 4:09am
stack-dashboard ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 4:09am
stack-demo ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 4:09am
stack-partial-prerendering ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 1, 2024 4:09am

Copy link

zeropath-ai bot commented Sep 25, 2024

Security

  • No security or compliance vulnerabilities detected
  • Scanned 9 changed file(s)

Changes Detected

  • [Feature] Added creator_user_id for team creation [crud.tsx, clientInterface.ts, serverInterface.ts]

    • Implemented in team creation endpoints and interfaces
    • Affects teamsCrudHandlers, createClientTeam, and createServerTeam functions
    • Allows specifying the creator of a team, replacing add_current_user query parameter
  • [Refactor] Deprecated add_current_user query parameter [crud.tsx]

    • Changed in teamsCrudHandlers function
    • Marked as hidden in OpenAPI field
    • Replaced by creator_user_id in request body
  • [Bug Fix] Added error checks for team creation [crud.tsx]

    • Implemented in onCreate function of teamsCrudHandlers
    • Prevents using both creator_user_id and add_current_user
    • Restricts client-side creation to only add the current user as creator
  • [Feature] Updated team creation in e2e tests [backend-helpers.ts, team-memberships.test.ts]

    • Modified Team.create helper function
    • Added new test cases for team creation scenarios
    • Covers creating teams without adding current user and adding different users as creators
  • [Refactor] Updated client and server interfaces for team creation [clientInterface.ts, serverInterface.ts]

    • Renamed createTeamForCurrentUser to createClientTeam
    • Removed session parameter from createServerTeam
    • Updated to use new creator_user_id field
  • [Feature] Added teamCreatorUserIdSchema [schema-fields.ts]

    • Defined new schema for team creator user ID
    • Added description and example value for OpenAPI documentation
  • [Refactor] Updated team creation in StackClientAppImpl and StackServerAppImpl [stack-app.ts]

    • Modified createTeam functions to use new creator_user_id field
    • Updated to match new interface methods

Copy link

Copy link

zeropath-ai bot commented Sep 25, 2024

Security

  • No security or compliance vulnerabilities detected
  • Scanned 14 changed file(s)

Changes Detected

  • [Refactor] Removed getIdFromUserIdOrMe function [FILE: route-handlers/utils.tsx]

    • Deleted the entire file containing this utility function
    • Function was used to handle 'me' as a user ID
  • [Refactor] Updated team creation logic [FILES: teams/crud.tsx, clientInterface.ts, serverInterface.ts]

    • Replaced add_current_user query parameter with creator_user_id in request body
    • Updated client and server interfaces to use new creator_user_id field
  • [Feature] Added validation for creator_user_id in team creation [FILE: teams/crud.tsx]

    • Prevents clients from adding a different user as the creator
    • Allows server-side creation with a specified creator
  • [Refactor] Updated team member profiles and permissions handling [FILES: team-member-profiles/crud.tsx, team-permissions/crud.tsx]

    • Removed usage of getIdFromUserIdOrMe function
    • Directly use params.user_id or query.user_id instead
  • [Refactor] Updated connected accounts access token handling [FILE: connected-accounts/[user_id]/[provider_id]/access-token/crud.tsx]

    • Removed usage of getIdFromUserIdOrMe function
    • Directly use params.user_id instead
  • [Feature] Added userIdOrMeSchema to various API endpoints [MULTIPLE FILES]

    • Implemented in team memberships, permissions, and other related endpoints
    • Allows 'me' as a valid user ID input
  • [Test] Added new test cases for team creation [FILE: team-memberships.test.ts]

    • Tests for creating teams without adding current user
    • Tests for creating teams with different users as creators

Copy link

Copy link

zeropath-ai bot commented Sep 25, 2024

Security

  • No security or compliance vulnerabilities detected
  • Scanned 14 changed file(s)

Changes Detected

  • [Refactor] Remove getIdFromUserIdOrMe utility function [apps/backend/src/route-handlers/utils.tsx]

    • Deleted the entire file containing the utility function
    • Function was used to handle 'me' as a user ID
  • [Refactor] Update team creation process [apps/backend/src/app/api/v1/teams/crud.tsx]

    • Added support for creator_user_id in the request body
    • Deprecated add_current_user query parameter
    • Updated logic to handle team creator assignment
  • [Feature] Allow server-side creation of teams with specific creator [apps/backend/src/app/api/v1/teams/crud.tsx]

    • Added ability to specify creator_user_id when creating a team
    • Implemented checks to prevent client-side abuse of this feature
  • [Refactor] Update client and server interfaces for team creation [packages/stack-shared/src/interface/clientInterface.ts, packages/stack-shared/src/interface/serverInterface.ts]

    • Renamed createTeamForCurrentUser to createClientTeam
    • Updated createServerTeam to remove session parameter
  • [Feature] Add teamCreatorUserIdSchema [packages/stack-shared/src/schema-fields.ts]

    • New schema for validating team creator user ID
  • [Test] Add new tests for team creation scenarios [apps/e2e/tests/backend/endpoints/api/v1/team-memberships.test.ts]

    • Tests for creating teams without adding current user
    • Tests for server-side team creation with different creator
    • Tests for client-side restrictions on team creation

Copy link

@N2D4 N2D4 changed the title Fix team creation on the server not automatically add the current user Fix team creation on the server not automatically adding the current user Sep 30, 2024
Copy link

zeropath-ai bot commented Oct 1, 2024

Security

  • No security or compliance vulnerabilities detected
  • Scanned 14 changed file(s)

Changes Detected

  • [Refactor] Remove getIdFromUserIdOrMe utility function [apps/backend/src/route-handlers/utils.tsx]

    • Deleted the entire file containing the utility function
    • Function was used to handle 'me' as a user ID
  • [Refactor] Update team creation process [apps/backend/src/app/api/v1/teams/crud.tsx]

    • Added support for creator_user_id in the request body
    • Deprecated add_current_user query parameter
    • Updated logic to handle team creator assignment
  • [Feature] Allow server-side creation of teams with specific creator [apps/backend/src/app/api/v1/teams/crud.tsx]

    • Added ability to specify creator_user_id when creating a team
    • Implemented checks to prevent client-side abuse of this feature
  • [Refactor] Update client and server interfaces for team creation [packages/stack-shared/src/interface/clientInterface.ts, packages/stack-shared/src/interface/serverInterface.ts]

    • Renamed createTeamForCurrentUser to createClientTeam
    • Updated createServerTeam to remove session parameter
  • [Feature] Add creator_user_id to team creation schemas [packages/stack-shared/src/interface/crud/teams.ts]

    • Added optional creator_user_id field to both client and server create schemas
  • [Test] Add new e2e tests for team creation scenarios [apps/e2e/tests/backend/endpoints/api/v1/team-memberships.test.ts]

    • Added tests for creating teams without adding current user
    • Added tests for server-side team creation with specific creator
    • Added tests to verify client-side restrictions on creator assignment

@fomalhautb fomalhautb deleted the fix-team-creation branch October 1, 2024 04:11
Copy link

github-actions bot commented Oct 1, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants