Lychee icon indicating copy to clipboard operation
Lychee copied to clipboard

Add backend and frontend for simple invitation links

Open ildyria opened this issue 6 months ago • 1 comments

This pull request introduces a new feature for generating user invitation links, along with several related improvements to user management functionality and API consistency. Key changes include the addition of an invitation link feature, updates to API endpoints for consistency, and enhancements to the registration process.

New Feature: User Invitation Links

  • Added invitationLink method in UserManagementController to generate temporary invitation links for user registration, leveraging signed URLs and configurable expiration (user_invitation_ttl). ([app/Http/Controllers/Admin/UserManagementController.phpR104-R130](diffhunk://#diff-78067725a56ae103bb435a6a4f662818e59354672e73e1611aeaec9c8bf0631eR104-R130))
  • Created a new Vue component InviteUser.vue to display and copy invitation links, with a user-friendly modal interface. ([resources/js/components/modals/InviteUser.vueR1-R58](diffhunk://#diff-466a49115ca708078eece0fde0c59e9b04087db2e01556abb011164caa2530aeR1-R58))
  • Added a new configuration option user_invitation_ttl to set the expiration time for invitation links, implemented via a migration. ([database/migrations/2025_06_10_220804_user_invitation_ttl.phpR1-R31](diffhunk://#diff-371532fd4ece9ca2e2a059e3fa21efc4918f4407465a83c34579d52f318ea18dR1-R31))

API Improvements

  • Updated API routes for user management to use RESTful conventions (POST, PATCH, DELETE) instead of custom route names (e.g., UserManagement::createUserManagement). ([routes/api_v2.phpL149-R152](diffhunk://#diff-dba9a30b214808bd1ac63349d1e384b6cbd8d80ef675e4bd7cf0d0ee31c961e8L149-R152))
  • Added a new UserManagement::invite route for generating invitation links. ([routes/api_v2.phpL149-R152](diffhunk://#diff-dba9a30b214808bd1ac63349d1e384b6cbd8d80ef675e4bd7cf0d0ee31c961e8L149-R152))

Registration Enhancements

  • Modified RegistrationRequest to forbid registration when the user is already logged in and to support signed URLs for invitation-based registration. ([app/Http/Requests/Profile/RegistrationRequest.phpL34-R40](diffhunk://#diff-a14ad85e096cbcd35a05e63e92db6d5363f763da28238a356d00c8eb66161af6L34-R40))
  • Updated ProfileService.register to include signature and expires parameters for handling signed invitations. ([resources/js/services/profile-service.tsL22-R32](diffhunk://#diff-03f9125d953b68763446d9a225c48b70b78dc9f445ff68db6e0c11b400ebd166L22-R32))
  • Enhanced the registration page (RegisterPage.vue) to parse and use query parameters for signed invitations. ([resources/js/views/RegisterPage.vueR97-R123](diffhunk://#diff-6b333490831101eb0d7bfa4568d85c036fbaf586fb06a3389bdfc722c08a3ef5R97-R123))

Frontend Updates for User Management

  • Added an "Invite User" button to the user management view (Users.vue) to trigger the invitation modal. ([resources/js/views/Users.vueL18-R20](diffhunk://#diff-3eda16e5e7df3d55625c0f7257195222933cfb9e2cd5c56e50401651b79e2e72L18-R20))
  • Integrated the UserManagementService.invite method to fetch invitation links. ([resources/js/services/user-management-service.tsL24-R36](diffhunk://#diff-16f54ae340fbc769b601a09480c0cc59198a8a0b6c7f1a6fda24a9c2c855d1a3L24-R36))

Tests and Validation

  • Added tests to validate the new invitation link functionality and ensure proper handling of registration under different conditions (e.g., logged-in users, disabled registration). ([tests/Feature_v2/User/RegisterTest.phpR87-R112](diffhunk://#diff-57449503a97137c1c3443211e5ce1b5e6996d8dcd74893830537c7794d8cfa5fR87-R112))
  • Updated existing tests for user creation, deletion, and editing to align with the new RESTful API routes. ([[1]](diffhunk://#diff-b99e6e5dbe7b9e5baccb137f5a90cdcca4da8d64ad22cf2daf831428c1d323ceL27-R38), [[2]](diffhunk://#diff-3910aff3f02feda247afa318f12b1edb192f9d2e2de7022ede133a40450542f2L28-R36), [[3]](diffhunk://#diff-2e508d1f97930e607aea350bea197c1834484959f97aceb24678cb5d3799f7efL27-R38))

ildyria avatar Jun 10 '25 22:06 ildyria

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 86.53%. Comparing base (ae1494c) to head (a237912). Report is 8 commits behind head on master.

:rocket: New features to boost your workflow:
  • :snowflake: Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • :package: JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

codecov[bot] avatar Jun 10 '25 22:06 codecov[bot]