Skip to content

2. Accounts

Since v0.3.0

Issues have authors, so the app needs accounts. One command writes them.

Add accounts

go tool anetos make:auth
go run . migrate

make:auth writes the code of accounts into your project, as files you own and can change:

FileHolds
app/models/user.goUser, and models.Users, which tells package auth how to find and update users
app/handlers/auth.go, app/handlers/settings.goRegistration, sign-in (with a password, Google or GitHub), email verification, password reset, two-factor sign-in, API tokens, the settings page
views/auth.templ, views/settings.templTheir pages, and AccountMenu, the header’s links to log in, register and log out, which make:auth adds to views/layout.templ
routes/auth.goTheir routes. Pages for signed-in users go in its members group
auth_test.goTheir tests

migrate creates the users, api_tokens and social_accounts tables.

Try it

Open http://localhost:8080/register and sign up. The app sends a link to verify your address: in development, emails go to the log (MAIL_DRIVER=log), so look in the terminal where anetos dev runs and open the link. You land on /dashboard (AUTH_HOME_URL sets another page; part 3 shows how); /settings changes your name, password, language and time zone.

go test ./... now runs the accounts’ tests too.

The accounts guide explains what’s there and how to change it.

Next: 3. Issues.