-
Notifications
You must be signed in to change notification settings - Fork 0
Auth: Invite system + registration endpoint #123
Copy link
Copy link
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
Auth System — Step 4 (Backend)
Invite-gated registration. No open signup — users must be invited by an admin/farm_owner/foreman.
Endpoints:
POST /api/auth/invites— create invite (admin/farm_owner → any role, foreman → worker only)GET /api/auth/invites/:token— validate invite (public, shows farm name + role)DELETE /api/auth/invites/:id— revoke inviteGET /api/farms/:farmId/invites— list pending invitesPOST /api/auth/register— accept invite, create account, auto-login
Registration flow:
- Validate invite token (not expired, not accepted)
- Create user (email/phone + bcrypt password)
- Create
user_farm_rolesentry - Link to existing
workersrow if phone matches - Mark invite as accepted
- Return tokens (user is logged in)
Implementation:
- Invite CRUD in
backend/src/routes/auth.js - Registration with invite validation
- Worker record linking (match phone + farm_id)
- Invite expiry: 72 hours default
- Role hierarchy enforcement on invite creation
Depends on: Login endpoints
Design doc: docs/AUTH.md
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request