Runique Admin

User creation via the admin panel

Full flow

When an admin creates a user through the panel, the cycle is:

Admin fills in the form
        ↓
Account created in database (is_active = false)
Random hash injected into the password field
        ↓
Reset email sent to the user
        ↓
User clicks the link
Sets their password
        ↓
update_password → is_active = true
        ↓
User can log in

What the framework does automatically

StepBuiltin behaviour
Creation via adminis_active = false — account is inactive at creation
password fieldRandom hash injected — the user never sees this value
EmailReset link sent to the address provided in the form
Password setupis_active is set to true automatically via update_password
Loginauth_login() blocks accounts with is_active = false

Builtin creation form — `UserAdminCreateForm`

The form provided by Runique (runique::admin::UserAdminCreateForm) exposes:

FieldTypeDescription
usernameText, requiredUsername (min. 3 characters)
emailEmail, requiredContact address + reset email recipient
passwordHiddenRandom hash injected automatically — not visible in the UI
is_staffBooleanRead access to the admin panel
is_superuserBooleanFull admin access

is_active is not in the form — accounts are always created inactive.


Configuration in `admin!{}`

admin! {
    users: eihwaz_users::Model => MyForm {
        title: "Users",
        permissions: ["admin"],
        create_form: runique::admin::UserAdminCreateForm,
        edit_form: crate::forms::UserEditForm,
    }
}

The create_form: field tells the daemon to use UserAdminCreateForm on creation and to enable the inject_password flag on the resource.


Email sending

The email is sent if the mailer is configured (SMTP_* variables in .env).

Without a mailer (development), the reset link is displayed in a flash message.

The default email template is admin/user_created_email.html. It can be overridden via AdminConfig::reset_password_email_template("my_template/email.html").

Tera context available in the template:

VariableValue
usernameUsername
emailEmail address
reset_urlFull reset link (absolute if reset_password_url is configured)

Reset URL

The constructed URL follows this pattern:

{base_url}/reset-password/{token}/{encrypted_email}

In production, configure reset_password_url in the builder to generate an absolute URL:

.with_admin(|a| a
    .reset_password_url("https://mysite.com/reset-password")
)

Without this configuration, the URL is built from the Host header of the HTTP request (http://{host}/reset-password/...).


Custom model

If the project uses its own user model (not eihwaz_users), it must implement UserEntity and handle is_active in update_password itself.

auth_login() uses BuiltinUserEntity — projects with a custom model call login() directly and control the is_active check in their own handler.