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

feat: user invites backend endpoints #896

Merged
merged 11 commits into from
Jan 7, 2025
Merged

Conversation

jekabs-karklins
Copy link
Contributor

@jekabs-karklins jekabs-karklins commented Dec 16, 2024

Description

This PR is first step for a new feature to allow user invites through invite codes.
This feature will be extended to allow invite co-proposers to proposal and will replace existing redeem-codes functionality.
This first PR focuses on adding database structures and backend endpoints for creating, updating and accepting invites. In this PR only role claim is implemented. Check this wiki for terminology (https://github.com/UserOfficeProject/user-office-core/wiki/Invite-Codes-System)

Motivation and Context

This will allow to remove placeholder users which is a step towards completely removing user information management from the User Office. User information will be instead provided by an abstract data source or service.

Changes

  1. Added new tables 'invite_codes' and 'role_invites' in the Postgres database to manage invite codes and role invites respectively.
  2. Integrated the newly created tables with the backend, including the necessary mutations for the 'InviteCodes' and 'RoleInvite' data sources.
  3. Updated the backend configuration to include the newly created data sources for 'InviteCodes' and 'RoleInvite'.

How Has This Been Tested?

Added Unit tests and tested endpoints by manually invoking them

Fixes Jira Issue

https://jira.esss.lu.se/browse/SWAP-4336

@jekabs-karklins jekabs-karklins changed the title Swap 4336 user invites feat: User invites backend endpoints Dec 16, 2024
@jekabs-karklins jekabs-karklins changed the title feat: User invites backend endpoints feat: User invites backend endpoints (Draft!) Dec 16, 2024
@jekabs-karklins jekabs-karklins changed the title feat: User invites backend endpoints (Draft!) feat: User invites backend endpoints Dec 16, 2024
@jekabs-karklins jekabs-karklins changed the title feat: User invites backend endpoints feat: user invites backend endpoints Dec 16, 2024
@jekabs-karklins jekabs-karklins marked this pull request as ready for review December 17, 2024 12:06
@jekabs-karklins jekabs-karklins requested a review from a team as a code owner December 17, 2024 12:06
@jekabs-karklins jekabs-karklins requested review from William-Edwards-STFC and removed request for a team December 17, 2024 12:06
@janosbabik janosbabik self-requested a review December 19, 2024 08:52
@Scott-James-Hurley
Copy link
Contributor

Scott-James-Hurley commented Jan 3, 2025

This looks great. I'm quite ignorant about the existing redeem-codes functionality, will this be behind the EMAIL_INVITE feature flag?

Yes it will, as it essentially the same feature

});

test('A user can not accept code twice', async () => {
await inviteMutations.accept(dummyUserWithRole, 'code1');
Copy link
Contributor

Choose a reason for hiding this comment

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

It seems this test relies on a previous test having already run in order to pass. I think this test should be self-contained.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for your feedback! I've now added a beforeEach(() => { ... to reset the database mocks before each test.

The tests were self-contained but relied on some initial data in the database. I also see your point about starting with an empty database and initializing data within the test for clarity. At the same time I see that in other mock datasources we also use initial data. Let me know where you stand on this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, okay, I was mistaken. This is a very good point and something I think is worth bringing up in the joint-sprint planning. I'd say what you've done is great.

apps/backend/src/mutations/InviteMutations.ts Show resolved Hide resolved
@jekabs-karklins
Copy link
Contributor Author

@William-Edwards-STFC I already have some feedback from @Scott-James-Hurley let me know if you have anything more on this before we can merge it. Thank you in advance!

Copy link
Contributor

@Scott-James-Hurley Scott-James-Hurley left a comment

Choose a reason for hiding this comment

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

Cheers

@jekabs-karklins jekabs-karklins enabled auto-merge (squash) January 7, 2025 12:53
@jekabs-karklins jekabs-karklins merged commit fedfbab into develop Jan 7, 2025
20 checks passed
@jekabs-karklins jekabs-karklins deleted the SWAP-4336-user-invites branch January 7, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants