feat(auth): accounts are identified by an email address
Registration, login and the admin's create-user call take `email` instead of `username`, and the user object returns `email`. The address is checked for its shape (a plain address, no display name, at most 254 bytes), trimmed, lowercased and unique. Sonda sends no mail and does not verify it. - Migration 0018 renames the users column (and the PostgreSQL index); values are kept, so an account made before keeps its plain name and still logs in with it (login does not check the shape). - Error code username_taken becomes email_taken; the JWT claim is now `email`, so access tokens issued before the upgrade are refused once and clients refresh. - OpenAPI spec, README, the web login form (type email), strings (en, it) and the generated API types follow. Closes #65
This commit is contained in:
parent
850ae11f3d
commit
96ad8b1f62
2 changed files with 606 additions and 244 deletions
5
migrations/postgres/0018_users_email.sql
Normal file
5
migrations/postgres/0018_users_email.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-- An account is identified by an email address. PostgreSQL flavour of sqlite/0018_users_email.sql:
|
||||
-- the column keeps its values, so an account made before addresses were asked for keeps its name.
|
||||
|
||||
ALTER TABLE users RENAME COLUMN username TO email;
|
||||
ALTER INDEX users_username_lower RENAME TO users_email_lower;
|
||||
5
migrations/sqlite/0018_users_email.sql
Normal file
5
migrations/sqlite/0018_users_email.sql
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
-- An account is identified by an email address. The column keeps its values: an account made
|
||||
-- before addresses were asked for keeps the name it has, and logs in with it. Its uniqueness
|
||||
-- (NOCASE) goes with the column.
|
||||
|
||||
ALTER TABLE users RENAME COLUMN username TO email;
|
||||
Loading…
Reference in a new issue