Skip to content

feat: add user groups, password reset, email notifications, API keys,…#2

Merged
stakach merged 2 commits intomasterfrom
feat/v2
Jan 13, 2026
Merged

feat: add user groups, password reset, email notifications, API keys,…#2
stakach merged 2 commits intomasterfrom
feat/v2

Conversation

@naqvis
Copy link
Contributor

@naqvis naqvis commented Dec 18, 2025

New Features

User Groups

  • Organize users within organizations with permission levels (Admin, Manager, User, Viewer)
  • Automatic "Administrators" group created for each organization
  • Group membership management with group admin roles
  • Invite users to groups via email (auto-adds to organization if needed)

Password Reset

  • Email-based password reset flow with secure tokens
  • Token expiration and single-use validation
  • New /auth/forgot-password and /auth/reset-password pages

Email Notifications

  • SMTP integration for transactional emails
  • Password reset emails
  • Organization and group invite emails
  • Mailpit added to docker-compose for local development

API Key Authentication

  • Bearer token authentication (Authorization: Bearer sk_...)
  • Scoped permissions per key
  • Optional expiration dates
  • Secure key hashing (raw key shown only once)

Audit Logging

  • Track user actions: login, logout, org/member changes
  • Captures IP address and user agent
  • Queryable audit trail per organization

Health Check Endpoints

  • GET /health - Basic health status
  • GET /health/live - Liveness probe
  • GET /health/ready - Readiness probe (checks database)

User Profile Page

  • View account information
  • Manage settings at /profile

UI Improvements

  • Organizations page: Search, pagination, sorting, responsive design
  • Dashboard: Modern layout with quick actions and account info cards
  • Landing page: Redesigned with feature highlights
  • Login page: Added "Forgot password?" link

Technical Changes

  • Added email shard for SMTP support
  • New database migrations:
    • groups, group_users, group_invites
    • audit_logs, api_keys, password_reset_tokens
    • Full-text search with tsvector
  • Enhanced permission checking with group-based access control
  • Pagination helper with Link headers and X-Total-Count
  • Updated OpenAPI spec with all new endpoints

@naqvis naqvis requested a review from stakach December 18, 2025 04:47
Copy link
Member

@stakach stakach left a comment

Choose a reason for hiding this comment

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

Looking great!
@naqvis I would obscure the password reset token in the database.

Similar to what we do here:
https://github.com/PlaceOS/models/blob/master/src/placeos-models/api_key.cr#L59

That will improve security significantly - bcrypt like we do for the users password is probably more secure again
What do you think?

@naqvis
Copy link
Contributor Author

naqvis commented Jan 12, 2026

Good call! 👍

I'll implement this following the API key pattern with HMAC-SHA512:

  • Split storage: id + hashed_secret
  • Return full token (id.secret) only on creation
  • Hash before storing, verify on lookup

@naqvis naqvis requested a review from stakach January 13, 2026 02:22
Copy link
Member

@stakach stakach left a comment

Choose a reason for hiding this comment

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

LGTM

@stakach stakach merged commit 05c00e6 into master Jan 13, 2026
1 check passed
@stakach stakach deleted the feat/v2 branch January 13, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants