Skip to content

Add user invitation system with UI and auto-accept feature - #114

Merged
ATechAdventurer merged 15 commits into
devfrom
cameron/eng-884-new-invite-flow
Sep 4, 2025
Merged

ATechAdventurer merged 15 commits into
devfrom
cameron/eng-884-new-invite-flow

Conversation

@ATechAdventurer

@ATechAdventurer ATechAdventurer commented Sep 2, 2025 •

Copy link
Copy Markdown
Member
Screenshot 2025-09-02 at 12 07 32 PM

Introduce a user invitation system that includes a UI for inviting users, CRUD operations for managing invites, and an auto-accept feature for pending invites during user registration. The implementation lays the groundwork for future enhancements to the invite functionality.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary of Changes

Hello @ATechAdventurer, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive user invitation system, enabling administrators to invite specific users to the platform and manage these invitations through a dedicated user interface. It also automates the acceptance of pending invites during user registration, significantly improving the user onboarding experience. The changes lay the foundation for future enhancements, such as domain-based invitations, and refine the existing user role management to be more robust and scalable.

Highlights

  • User Invitation System API Endpoints: Introduced new API routes for managing user invitations, including creation, retrieval, acceptance, and deletion of individual invites. Placeholder endpoints for domain invites are also added, marked as 'Coming Soon'.
  • User Interface for Invite Management: A new UI component, UsersDetails.tsx, has been added to the settings panel, providing administrators with a dedicated interface to invite users, view pending invitations, and manage them. This includes a 'Coming Soon' section for domain-based invitations.
  • Automated Invite Acceptance on User Registration: The authentication configuration has been updated to automatically accept pending user invitations when a user with a matching email successfully registers or logs in, streamlining the onboarding process for invited users.
  • Enhanced User Role Management: The user management API and UI have been refactored to support a more flexible role system. This includes the ability to fetch users with and without assigned roles, and a new mechanism to update user roles, moving away from a simple 'ADMIN'/'MEMBER' distinction to a more granular role assignment.
  • Database Schema Updates: A new Prisma model, UserInvite, and an InviteStatus enum have been added to the database schema to support the storage and management of user invitation data, including invite status, expiration, and associated roles.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution. ↩

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a comprehensive user invitation system, including backend services, API routes, UI components, and database changes. The implementation is solid, with good use of zod for validation and clear separation of concerns. However, there are a few critical and high-severity issues that should be addressed. The most critical is the lack of an atomic transaction when accepting an invite, which could lead to data inconsistency. Several API routes have brittle error handling based on string matching, which should be refactored to use custom error classes for better maintainability. There are also some incorrect type definitions for route handler parameters and a missing @updatedAt directive in the Prisma schema. On the frontend, there are opportunities to improve performance and consistency by using useCallback for event handlers and a dedicated library for date formatting.

Comment thread app/lib/services/inviteService.ts Outdated
Comment thread app/api/domain-invites/[domainId]/route.ts Outdated
Comment thread app/api/invites/[inviteId]/route.ts Outdated
Comment thread app/api/invites/[inviteId]/route.ts Outdated
Comment thread app/api/invites/accept/route.ts
Comment thread app/api/invites/route.ts
Comment thread prisma/schema.prisma Outdated
Comment thread app/components/@settings/tabs/users/UsersDetails.tsx Outdated
Comment thread app/components/@settings/tabs/users/UsersTab.tsx Outdated
ATechAdventurer and others added 7 commits September 2, 2025 11:53
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

@bears4barrett bears4barrett left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we can rely on the first role being the "primary", and only returned role for a user.

If someone later adds "Admin" role to a user, it may be their second or third role, but would be their highest scoped role.

I think we should join on all roles for users if necessary in the response. This was added, but I think it got lost / removed in one of the big merges of schema changes.

Here was the PR that included joining on roles to user profiles in the userService file:
https://github.com/liblaber/ai/pull/38/files#diff-6bb902f2736bbe37874a2396d2e61470077ef3d56da384f60a480c16284f2f40

…le mapping. Added UserRole interface and updated user retrieval methods to support roles. Refactored user selection logic for consistency and clarity.
…ching and displaying of pending invites, along with functionality to delete invites. Enhanced user filtering to include invites.
@bears4barrett

Copy link
Copy Markdown
Contributor

We now have a logger over console

…. Added email validation, dynamic email input handling, and improved invite submission for multiple emails. Updated UI to display invited emails with removal options and adjusted button states based on invite status.
Comment thread app/api/domain-invites/route.ts
Comment thread app/api/invites/[inviteId]/route.ts Outdated
… improved logging consistency. Updated error logging in GET, POST, and DELETE methods across invites, accept invites, and invite management routes.
@ATechAdventurer
ATechAdventurer merged commit aad5146 into dev Sep 4, 2025
4 checks passed
@ATechAdventurer
ATechAdventurer deleted the cameron/eng-884-new-invite-flow branch September 4, 2025 19:41
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.

3 participants