Skip to content
This repository was archived by the owner on Jan 1, 2026. It is now read-only.

Conversation

@Vianpyro
Copy link
Member

Description

This pull request introduces several major improvements to the database schema and stored procedures related to user authentication and registration. It adds support for email verification, improves data integrity with better constraints, supports OTP (2FA), and simplifies logic for maintainability.

Changes Made

  • Refactored register_user procedure and updated schema for stricter username validation.
  • Changed parameter types from VARCHAR to TEXT in authenticate_user and register_user functions for consistency.
  • Fixed parameter order in register_user procedure to align with schema expectations.
  • Added is_user_available function to check for existing users by email.
  • Updated register_user to accept language_id directly and improved schema constraints on users and languages tables.
  • Simplified register_user by removing exception handling and streamlining user insertion logic.
  • Enhanced task configuration: added Docker-related tasks for building/running containers and improved formatting.
  • Enforced password_hash format using a constraint for Argon2id compliance.
  • Renamed is_user_available to is_email_available for clarity and created pending_users table to support email confirmation workflow.
  • Reintroduced is_email_available with updated logic to check across both users and pending_users.
  • Refactored registration/authentication processes: removed authenticate_user, improved is_email_available, and added stored procedures for handling pending users.
  • Implemented OTP secret storage in register_user, added support for HOTP in login flow, and enforced 24-hour expiration on email verification tokens.

How to Test

  1. Apply the updated SQL migrations or rebuild the database from the latest schema.
  2. Attempt to register a user — verify the data is stored in pending_users and a token is generated.
  3. Confirm the email via token — ensure the user is moved to the users table.
  4. Test login with and without 2FA.
  5. Check that Argon2id hashes are required and invalid hashes are rejected.
  6. Confirm constraints on usernames, emails, and language IDs work as expected.

Checklist

  • My code follows the project's coding style.
  • I have performed a self-review of my code.
  • I have added necessary tests (if applicable).
  • I have documented my changes (if necessary).

Additional Context

This update enables a more secure and structured user onboarding process. It enforces best practices like unique pending registrations, hash validation, email confirmation delays, and support for OTP-based two-factor authentication, while simplifying stored procedures and constraints for better maintainability.

Vianpyro added 13 commits June 9, 2025 10:07
…e schema constraints for user and language tables
…plify user insertion logic; delete obsolete authentication test file.
…g, running, and managing Docker containers; improve formatting for better readability.
…; update users table to enforce discriminator constraint and add pending_users table for email verification
…ete authenticate_user function, enhance is_email_available function, and implement procedures for creating and managing pending users.
… in register_user procedure, update authentication methods to include HOTP, and implement verification token validity check with a 24-hour constraint.
@Vianpyro Vianpyro self-assigned this Jun 12, 2025
@Vianpyro Vianpyro added complexity: complex Tasks with unclear paths that need exploration or experimentation. priority: high Important tasks that require immediate attention. special: breaking change Tasks that will introduce a breaking change and require careful implementation. status: needs review Ready for code or design review. type: feature Requests for new functionality or features. type: security Issues or improvements related to app security. type: refactor Improvements to existing code without changing functionality. labels Jun 12, 2025
@Vianpyro Vianpyro force-pushed the feature/secure_registration_add_login branch from b4ca1e2 to d65070c Compare June 13, 2025 02:08
Vianpyro and others added 7 commits June 13, 2025 13:01
…ry in postAttachCommand and format dependencies for clarity
…update last login and updated timestamps, and create triggers for automatic timestamp updates.
…d create_user_refresh_token to expire old tokens and insert new ones, and remove obsolete end_user_session procedures.
@Vianpyro Vianpyro merged commit b45649c into main Jun 22, 2025
5 of 9 checks passed
@Vianpyro Vianpyro deleted the feature/secure_registration_add_login branch June 22, 2025 11:46
@Vianpyro Vianpyro added status: completed Fully implemented and verified. and removed status: needs review Ready for code or design review. labels Jun 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

complexity: complex Tasks with unclear paths that need exploration or experimentation. priority: high Important tasks that require immediate attention. special: breaking change Tasks that will introduce a breaking change and require careful implementation. status: completed Fully implemented and verified. type: feature Requests for new functionality or features. type: refactor Improvements to existing code without changing functionality. type: security Issues or improvements related to app security.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants