Skip to content

Ilogeek/flatboard-registrationcode

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Registration Code Plugin for Flatboard

Version License Flatboard PHP Category

A security plugin for the Flatboard forum application (flatboard.org) that enforces mandatory registration code requirements for user registration. Provides an administrative interface to configure a secret code and a customizable help message displayed on the registration form.

Table of Contents

Description

The Registration Code Plugin adds an additional layer of security to your Flatboard forum by requiring users to enter a secret code during registration. This prevents unauthorized sign-ups and helps control access to your forum. Administrators can easily configure the registration code and customize the help message displayed to users through the Flatboard admin panel.

This plugin integrates seamlessly with Flatboard's plugin system and extends the standard registration flow to enforce code validation before allowing new user accounts to be created.

Features

  • Mandatory Registration Code: Requires users to enter a valid code before registration on Flatboard
  • Admin Configuration Interface: Easy-to-use Flatboard admin panel for code and message management
  • Real-time Validation: AJAX-based validation with instant feedback
  • Client-side Validation: JavaScript validation for immediate user feedback
  • Security Logging: Automatic logging of failed registration attempts for monitoring
  • Input Sanitization: All user inputs are sanitized to prevent XSS attacks
  • Internationalization: Built-in support for English and French languages
  • Customizable Help Message: Display contextual information to guide users
  • Seamless Integration: Hooks into Flatboard's registration form automatically

Installation

Prerequisites

Ensure your Flatboard installation meets the System Requirements before installation.

Steps

  1. Clone the repository:
git clone https://github.com/ilogeek/flatboard-registrationcode.git /path/to/plugins/registrationCode
  1. Verify the plugin structure:
/plugins/registrationCode/
├── plugin.json
├── RegistrationCodePlugin.php
├── langs/
│   ├── en.json
│   └── fr.json
├── assets/
│   └── js/
│       └── registration.js
└── README.md
  1. Activate the plugin through the Flatboard admin panel:

    • Navigate to Admin > Plugins
    • Find "Registration Code" in the plugin list
    • Click "Activate" or set "active": "1" in the plugin configuration
  2. Configure the plugin by accessing the plugin settings page and setting your registration code and help message.

Usage

Basic Usage

Once installed and activated, the plugin automatically:

  1. Injects a registration code field into the Flatboard registration form
  2. Validates the code before allowing registration to proceed
  3. Displays the help message below the code field
  4. Logs failed attempts for security monitoring

Registration Form

Users will see an additional field on the Flatboard registration page:

<label for="registration_code">Registration Code</label>
<input 
    type="text" 
    id="registration_code" 
    name="registration_code" 
    required 
    placeholder="Enter registration code"
    autocomplete="off"
>
<small class="form-text text-muted">Contact the administrator to obtain the registration code.</small>

Admin Configuration

Access the plugin settings through the Flatboard admin panel:

  1. Navigate to Admin > Plugins > Registration Code
  2. Configure the following settings:
    • Registration Code: The secret code users must enter
    • Help Message: Custom message displayed below the input field

Configuration

Plugin Settings

The plugin can be configured through the Flatboard admin interface or by editing plugin.json:

Setting Type Default Description
code string CODE-SECR3T The secret registration code required for user registration
message string Contact the administrator to obtain the registration code. Help message displayed on the registration form

Configuration Example

{
    "settings": {
        "code": "MY-SECRET-CODE",
        "message": "Please contact support@yourdomain.com to request access."
    }
}

System Requirements

  • Flatboard Version: 5.0.0 or higher
  • PHP Version: 7.4 or higher
  • Extensions:
    • JSON extension (for plugin configuration)
    • Session support
  • Web Server: Apache with mod_rewrite or Nginx
  • Browser Support: Modern browsers with JavaScript enabled

Security Features

Input Sanitization

All user inputs are sanitized using Flatboard's Sanitizer class to prevent XSS attacks:

$submittedCode = $this->sanitizeInput($request->get('registration_code'));

Failed Attempt Logging

Invalid registration code attempts are logged for security monitoring:

Logger::security('Invalid registration code attempt', [
    'ip' => $request->getIp(),
    'submitted_code' => $submittedCode,
    'timestamp' => date('Y-m-d H:i:s')
]);

CSRF Protection

The plugin integrates with Flatboard's CSRF middleware for form protection.

API Endpoints

Validate Registration Code

Validates a registration code via AJAX.

Endpoint: POST /api/plugins/registrationcode/validate

Request Parameters:

Parameter Type Required Description
registration_code string Yes The registration code to validate

Response:

Success (200):

{
    "valid": true
}

Failure (200):

{
    "valid": false,
    "message": "Invalid registration code. Please contact the administrator for access."
}

Registration with Code

The plugin intercepts the standard Flatboard registration endpoint to enforce code validation.

Endpoint: POST /register

Request Parameters:

Parameter Type Required Description
registration_code string Yes The registration code
... ... ... Standard Flatboard registration fields

Internationalization

The plugin supports multiple languages through JSON language files.

Supported Languages

  • English (en)
  • French (fr) - Default

Adding a New Language

  1. Create a new language file in the langs/ directory (e.g., es.json)
  2. Follow the structure of existing language files:
{
    "registrationCode": {
        "field": {
            "label": "Registration Code",
            "placeholder": "Enter registration code"
        },
        "validation": {
            "codeRequired": "Please enter a registration code.",
            "codeInvalidPattern": "Registration code can only contain letters, numbers, and hyphens.",
            "codeInvalid": "Invalid registration code. Please contact the administrator for access.",
            "validationError": "Error validating registration code. Please try again."
        }
    },
    "code_help": "The secret code users must enter to register.",
    "message_help": "This message will be displayed below the registration code field on the registration form to help users understand how to obtain access."
}
  1. Update the plugin.json file to include the new language:
{
    "i18n": {
        "languages": ["en", "fr", "es"],
        "directory": "langs",
        "default": "fr"
    }
}

Contributing

Contributions are welcome! Please follow these guidelines:

Development Setup

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/my-feature
  3. Make your changes following the existing code style
  4. Test thoroughly on a Flatboard development environment

Code Style

  • Follow PSR-12 coding standards for PHP
  • Use descriptive variable and function names
  • Add inline comments for complex logic
  • Maintain existing documentation

Submitting Changes

  1. Commit your changes with clear messages
  2. Push to your fork: git push origin feature/my-feature
  3. Submit a pull request with a description of your changes

Reporting Issues

If you find a bug or have a feature request:

  1. Check existing issues to avoid duplicates
  2. Create a new issue with:
    • Clear title and description
    • Steps to reproduce (for bugs)
    • Expected vs actual behavior
    • Environment details (PHP version, Flatboard version)
    • Relevant logs or screenshots

License

This plugin is licensed under the MIT License. See the LICENSE file for details.

Author

Hugo Zilliox

Support

For support, questions, or feature requests, please:

  • Open an issue on GitHub
  • Visit the project homepage
  • Contact the author through the official website
  • Visit Flatboard for community support

Note: This plugin is designed specifically for the Flatboard forum application (flatboard.org). Ensure you are using a compatible version of Flatboard (5.0.0 or higher) before installation.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors