Repository navigation
How To Sign In with an Email
How to let people sign in with their email address. The simplest way keeps the users table as it is: the
username column holds the address, in lower case. Route::auth, passkeys, the throttle and $user['username'] keep
working, with no new column. It takes a wider column, two rules, two form fields and two messages. Since 2.19.0.
Say it in your idea or your request:
"people sign in with their email, kept in the username column"
/caligrafy-quill:idea puts it in the plan and writes the steps below.
Check: a sign-up with Ada@Example.COM lands in users.username as ada@example.com, and signing in as
ADA@example.com works.
-
The column. An address can be 254 characters. Before the table exists, write
username varchar(254) NOT NULLinapplication/models/Auth/create_db.sql. For a table that exists, rundocker compose exec dev-box php caligrafer.php migrate make username_holds_email, write in the file it names:and run-- username_holds_email ALTER TABLE users MODIFY username varchar(254) NOT NULL;
docker compose exec dev-box php caligrafer.php migrate. -
The rules. In
application/services/Users/CaligrafyRegisterUser.php, replace the$rulesline with:and inpublic $rules = array('username' => 'required|valid_email|max_len,254', 'passcode' => 'required|min_len,8|max_len,72'); public $filters = array('username' => 'trim|lower_case');
application/services/Users/CaligrafyUpdateUser.phpmake the rule ofusername'valid_email|max_len,254'and addpublic $filters = array('username' => 'trim|lower_case');. A laterupdatekeeps these two files and writes the release's copies next to them as.caligrafy-new. -
The forms. In
application/views/Auth/login.pug, replace the- $field,- $isEmaillines and the.cq-fieldof the identifier with:In.cq-field label(for='username') Email input#username.form-control(type='email', name='username', value=isset($user) && is_object($user) ? ($user->username ?? '') : '', required, autocomplete='email', autocapitalize='none', maxlength='254')
application/views/Auth/register.pug, change thep.cq-leadline top.cq-lead Your email address, and at least 8 characters for the password.and the first.cq-fieldto:The field stays named.cq-field label(for='username') Email input#username.form-control(type='email', name='username', value=$user->username?? '', required, autocomplete='email', autocapitalize='none', maxlength='254') if isset($errors['username']) p.cq-field-error= $errors['username']
username. A sign-up page of your own changes the same way. -
The words, in the messages of
Route::auth:Route::auth(['home' => '/books', 'messages' => [ 'invalid' => 'Invalid email or password', 'register_taken' => 'An account already uses this email', ]]);
- Try it.
| You do | You get |
|---|---|
Create account with not an email
|
A few details need a fix: see the notes under the fields., with the field's message under it |
Create account with Ada@Example.COM
|
302 to /login; SELECT username FROM users shows ada@example.com
|
| The same address again | An account already uses this email |
Sign in as ADA@example.com
|
302 to home: the username column ignores case |
| A wrong password | Invalid email or password |
When you need both a username and an address, Route::auth(['identifier' => 'email']) signs in with the email column,
and the shipped login.pug names its field after $identifier. The shipped users table has no email column and
register_user asks for a username: add the column in a migration
and write your own sign-up capability ('register' => 'register_reader') whose $rules declare email. The lookup is
the model's findBy($column, $value) (the shipped User has it), else a bound query on its table.
-
'identifier' => 'email'with the shipped views and table (G133): the POST field is named after the identifier, so ausernamefield no longer signs in; and the table needs anemailcolumn. -
The sign-up refuses an address (G75): the shipped
register_useraccepts letters and digits only, until its rules change as in step 2. -
A mixed-case address in the table: the
lower_casefilter keeps them all in lower case.
- Sign-in, users and tokens
-
How to reset a password: with the address in
username, no new column - Migrations
- API: Caligrafy\AuthRoutes
Caligrafy: Describe it. Approve it. Ship it. Your idea turned into a complete app: every feature built once, for web pages, Vue apps, a REST API and AI agents, and online.
Why Caligrafy: the benefits, the measurements, and what it is not yet
-
Quickstart with Claude: describe it, approve it, ship it
or the Quickstart: the same three steps by hand, in 5 minutes
- How Caligrafy works: the ideas in 5 minutes
- Your first capability: build a feature, page included
-
Capabilities in depth
-
#[Capability]: every option - Scheduled jobs: capabilities on a timer
- Notifications: web push and email
- Background jobs: capabilities run later
- Migrations: database changes, in order
- The cache
-
Testing your app
- Dependency injection
- Validation rules
-
Web pages
- Views and page components
- Design styles: another look, one setting
- Declarative routes: every request, in one line
-
Route::page·Route::form·Route::auth·Route::webhook·Route::download·Route::redirect·Route::action·Route::snap· capability routes - How to export a list as CSV
- Controllers: moving one to a declared route · how to, step by step
- Forms and helpers
-
Vue apps
-
Mobile and tablet
-
REST API
-
AI agents
-
Snap Cards and the assistant
- Payments: Stripe and crypto
- Face detection and face login
- OpenAI: chat and images · Assistants
- Open models: Llama, Mistral...
- Chatbots with Watson
- Machine learning in the browser
- Metadata and social cards · search and analytics
-
Putting it online: the production image, the database at every start
-
API reference: every class and method
-
Routing ·
Route·AuthRoutes· pages ·Controller· capabilities -
Data ·
Model·Query· sign-in · jobs ·Notify· payments · AI -
Interfaces · Snap ·
Snap\Cards·Snap\Conversation· testing · tooling · helper functions
-
Routing ·
-
Caligrafer: every command
- Project · build · data · agents · jobs and tests · maintenance · deploy
- Installation, configuration and Caligrafer
- Routing · Request · Controllers · Views
- Vue: flow of information · routes · validations
- Security and upgrading
- Release notes: 2.26 · 2.25 · 2.24 · 2.23 · 2.22 · 2.21 · 2.20 · 2.19 · 2.18 · 2.17 · 2.16 · 2.15 · 2.14 · 2.13 · 2.12 · 2.11 · 2.10 · 2.9 · 2.8 · 2.7 · 2.6 · 2.5 · 2.4 · 2.3 · 2.1 · October 2026 · changelog
- Testing Caligrafy (contributors)