feat(backend): invite system + user management
- InviteToken model with unique token for each invite
- POST /users/invite - create invite by email with role (admin/mecanic)
- POST /auth/accept-invite - accept invite, set password, return JWT
- GET /users - list all users in tenant
- DELETE /users/{id} - deactivate user (cannot deactivate owner)
- Alembic migration for invites table
- 25 passing tests (auth + sync + orders + pdf + portal + invoices + users)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -15,6 +15,7 @@ from app.db.models.catalog import (
|
||||
from app.db.models.invoice import Invoice
|
||||
from app.db.models.appointment import Appointment
|
||||
from app.db.models.mecanic import Mecanic
|
||||
from app.db.models.invite import InviteToken
|
||||
|
||||
__all__ = [
|
||||
"Tenant",
|
||||
@@ -32,4 +33,5 @@ __all__ = [
|
||||
"Invoice",
|
||||
"Appointment",
|
||||
"Mecanic",
|
||||
"InviteToken",
|
||||
]
|
||||
|
||||
12
backend/app/db/models/invite.py
Normal file
12
backend/app/db/models/invite.py
Normal file
@@ -0,0 +1,12 @@
|
||||
from sqlalchemy import String, Text
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from app.db.base import Base, UUIDMixin, TenantMixin, TimestampMixin
|
||||
|
||||
|
||||
class InviteToken(Base, UUIDMixin, TenantMixin, TimestampMixin):
|
||||
__tablename__ = "invites"
|
||||
email: Mapped[str] = mapped_column(String(200))
|
||||
rol: Mapped[str] = mapped_column(String(20))
|
||||
token: Mapped[str] = mapped_column(String(36), unique=True, index=True)
|
||||
used: Mapped[str | None] = mapped_column(Text) # ISO8601 when used, null if pending
|
||||
Reference in New Issue
Block a user