# 2. Accounts

Source: https://docs.anetos.dev/main/getting-started/tutorial/02-accounts/

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

## Add accounts

```sh
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:

| File | Holds |
|---|---|
| `app/models/user.go` | `User`, and `models.Users`, which tells package `auth` how to find and update users |
| `app/handlers/auth.go`, `app/handlers/settings.go` | Registration, login (with a password, Google or GitHub), email verification, password reset, two-factor authentication, API tokens, the settings page |
| `views/auth.templ`, `views/settings.templ` | Their pages, and `AccountMenu`, the header's links to log in, register and log out, which `make:auth` adds to `views/layout.templ` |
| `routes/auth.go` | Their routes. Pages for logged-in users go in its `loggedIn` group |
| `auth_test.go` | Their tests |
| `database/factories/users.go` | `factories.Users`, which makes users for your own 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](https://docs.anetos.dev/main/guides/accounts/index.md) explains what's there and
how to change it.

Next: [3. Issues](https://docs.anetos.dev/main/getting-started/tutorial/03-issues.md).
