Skip to content

Add configurable registration modes: open, code-based, and closed - #124

Merged
itshypax merged 8 commits into
updatefrom
copilot/fix-login-config-variable
Nov 2, 2025
Merged

Add configurable registration modes: open, code-based, and closed#124
itshypax merged 8 commits into
updatefrom
copilot/fix-login-config-variable

Conversation

Copilot AI commented Nov 2, 2025

Copy link
Copy Markdown
Contributor

Implements three registration modes controlled via REGISTRATION_MODE constant in /assets/config/config.php:

define('REGISTRATION_MODE', 'open');   // Default: anyone can register
define('REGISTRATION_MODE', 'code');   // Requires unique invitation code
define('REGISTRATION_MODE', 'closed'); // No new registrations

Changes

Configuration

  • Added REGISTRATION_MODE constant to assets/config/config.php
  • Default value: 'open' (preserves existing behavior)

Authentication Flow

  • Modified auth/callback.php to check registration mode before user creation
  • In code mode: redirect new users to login page for code entry, validate code, mark as used
  • In closed mode: redirect to login page with error message
  • In open mode: unchanged behavior (auto-create with default role)

Admin Interface

  • Created benutzer/registration-codes.php for code management
  • Requires admin or users.manage permission
  • Generate 16-character random codes, view usage history, delete unused codes

User Interface

  • Updated login.php to handle code entry directly on the login page
  • Login page dynamically shows code input form when required (?require_code=1)
  • Displays mode-specific messages and error handling
  • Session-based error messages for better user experience

Database

  • New table intra_registration_codes tracks codes, creator, and usage
  • Migration: create_intra_registration_codes_02112025.php

Security

  • XSS protection via htmlspecialchars() on error messages
  • Prevent deletion of used codes via WHERE is_used = 0
  • Optimized existence checks with SELECT 1 instead of full row fetch

User Flow

UI Changes

All registration interactions happen on the main login page:

  • Open mode: Standard Discord login button
  • Code mode: After Discord auth, new users see code entry form inline
  • Closed mode: New users see error message on login page

Fixes #123

Original prompt

This section details on the original issue you should resolve

<issue_title>Config-Variable für Login</issue_title>
<issue_description>1. Registrierung für jeden möglich
2. Registrierung nur mit einzigartigem Code (mit eigener Berechtigung erstellbar)
3. Keine Registrierung für neue Personen möglich</issue_description>

Comments on the Issue (you are @copilot in this section)


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits November 2, 2025 16:23
Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>
Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>
@itshypax
itshypax self-requested a review November 2, 2025 16:26
Copilot AI and others added 2 commits November 2, 2025 16:27
Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>
Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix login configuration variable issues Add configurable registration modes: open, code-based, and closed Nov 2, 2025
@itshypax

itshypax commented Nov 2, 2025

Copy link
Copy Markdown
Collaborator

@copilot When registration mode is "closed" redirect the user back to the login page with the warning/error message. Also handle entering the registration code (if required) on the normal login page.

Co-authored-by: itshypax <33388336+itshypax@users.noreply.github.com>
Comment thread docs/REGISTRATION_MODES.md Outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Für die Landingpage bzw. Wiki gut, nicht im Repo hier

Copilot AI commented Nov 2, 2025

Copy link
Copy Markdown
Contributor Author

@copilot When registration mode is "closed" redirect the user back to the login page with the warning/error message. Also handle entering the registration code (if required) on the normal login page.

Done in commit 6fdf773.

Changes made:

  1. When registration mode is "closed", users are now redirected back to the login page with an error message instead of showing a plain error page
  2. Registration code entry is now handled directly on the login page (no separate page)
  3. The login page dynamically shows the code input form when required

UI Flow:

  • Normal login: Shows standard Discord login button
  • Code mode: After Discord auth, new users are redirected to login page with ?require_code=1 parameter, which displays the code entry form
  • Closed mode: New users attempting to register are redirected back to login page with error message

UI Changes

The screenshot above shows all scenarios including the code entry form integrated into the login page.

Copilot AI requested a review from itshypax November 2, 2025 16:36
@itshypax
itshypax marked this pull request as ready for review November 2, 2025 16:39
@itshypax
itshypax merged commit 3721c0f into update Nov 2, 2025
@itshypax
itshypax deleted the copilot/fix-login-config-variable branch November 2, 2025 16:39
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