Skip to content
GrumpyCrouton edited this page Aug 12, 2022 · 1 revision

About GF3 Auth Module

This is a module that can be dropped into GF3 to provide login and registration functionality. Integrated using GrumpyPDO, it relies on using a MySQL database.

Installation

  • Drop into a folder called auth in your GF3 installations modules folder
  • Set up the auth table using the auth.sql file in the module root
  • Alter settings.json to your liking

Features

  • Registration functionality
  • Login functionality
  • Stores passwords as hash for security
  • Simple form generator to control fields and required fields through the settings file
    • Currently limited to regular input html elements for simplicity, but could be expanded upon
  • Register/Login forms generated from the same base template (views/form.htm)

Form Template

Features

  • Error box. Used when the server has an issue with a registration or login attempt
  • Form field generator
    • The example below loops over all of the fields for either the login or registration page to generate the form.
    • On each loop, two variables will be set
      • @readable - Readable name of the field. Replaces underscores with spaces and runs ucwords().
      • @required - A boolean to easily check if the field is a required one (based on settings)

Example

<check if="{{ @GET.error }}">
    <div class="ui negative message">
        <i class="close icon"></i>
        <div class="header">
            Error
        </div>
        <p>{{ @GET.error }}</p>
    </div>
</check>
<repeat group="{{ @fields }}" key="{{ @field }}" value="{{ @field_data }}">
    <set readable="{{ @field_data->label ?: ucwords(str_replace('_', ' ', @field)) }}"/>
    <set required="{{ @field_data->required ?: false }}"/>
    <div class="field">
        <label>
            {{ @readable }}
            <check if="{{ @required }}">
                {{ '<span class="ui red text">*</span>' }}
            </check>
        </label>
        <input type="{{ @field_data->type }}" name="{{ @field }}" placeholder="{{ @readable }}" {{ @required ? 'required' : '' }}>
    </div>
</repeat>

image image

Un-stylized

image image

Default Settings

{
    "successful_login_path": "default",
    "database_columns_for_user_session": ["uid", "username"],
    "register_fields": {
        "username": {
            "type": "text",
            "required": true
        },
        "email": {
            "type": "email",
            "required": true
        },
        "password": {
            "type": "password",
            "required": true
        },
        "verify_password": {
            "type": "password"
        }
    },
    "login_fields": {
        "identifier": {
            "type": "text",
            "label": "Username or Email",
            "required": true
        },
        "password": {
            "type": "password",
            "required": true
        }
    }
}