User
The host application's User model, into which Trek injects authentication (Sorcery), roles, theme & locale preferences and the invitation workflow.
Columns added by Trek
| Column | Type | Notes |
|---|---|---|
name | string | display name |
role | integer | enum, default guest |
theme | integer | enum, default auto |
locale | string | admin UI language |
Plus the Sorcery authentication columns (email, crypted_password, reset tokens…).
Roles
Trek::Users::Roles defines the role enum and access levels:
enum :role, { admin: 5, editor: 4, user: 3, reader: 2, guest: 1 }, default: "guest"privileged?—trueforadminandeditor; this is what the default policies checkUser.human_roles— translated role names for form selects
Themes
Trek::Users::Themes lets each user pick the admin theme:
enum :theme, { auto: 0, light: 1, dark: 2 }, default: "auto"User.human_themes returns translated theme names.
Locales
Trek::Users::Locales provides User.human_locales — the available admin UI languages with translated labels, sourced from I18n.available_locales.
Invitations
Trek::Users::Invitable adds a transient send_invite flag: when set on creation, the user receives an invitation email with a password-reset link.
User.create(email: "new@example.com", role: :editor, send_invite: true)Validations
Trek::Users::Validations enforces:
email— presence, uniqueness, valid formatpassword— minimum 8 characters (on creation or password change)
Scopes
Trek::Users::Scopes adds User.ordered — alphabetical by name, then email.
Form models
Two non-persisted ActiveModel::Model companions handle the auth flows:
Trek::UserSession—email+password, used by the login formTrek::UserPasswordReset—email, looks up theuserto send a reset link to