Repository navigation
Add employee management with email invites and last-admin protection - #2
Merged
Merged
Conversation
- POST /api/v1/employees creates login, employee and roles in one transaction - Emails the set-password link after commit; failure is logged and reported (inviteEmailSent) - Duplicate employee code returns 409; FakeEmailSender replaces SMTP in API tests
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.
Summary
Administrators can now manage their distributor's employees end to end:
invite by email, set password, edit, change roles, deactivate and reactivate.
Completes build step 2 (login and users).
Endpoints
/api/v1/employees,/api/v1/employees/{id}/api/v1/employees(invite)/api/v1/employees/{id}/resend-invite/api/v1/employees/{id}(profile)/api/v1/employees/{id}/roles/api/v1/employees/{id}/deactivate,/reactivate/api/v1/auth/set-passwordNotable design decisions
3-day token is emailed (MailKit over SMTP; Mailpit for local dev).
Email is sent after commit; failure is logged and reported, with resend available.
(
SELECT ... FOR UPDATE) so two admins demoting each other concurrentlyalways leave exactly one. Concurrency tests fail when the lock is removed.
index; reactivation returns 409 if the email is now active elsewhere.
UnitOfWorkto a provider-neutralexception, so the Application layer has no EF/Npgsql dependency.
Testing