Wraith. Accounts
(Wraith v0.1.0)
View Source
Who writes here. The first user is the owner (created at /setup);
owners add authors. Passwords are bcrypt; a login mints a random session
token whose SHA-256 is the key of a session item (60 days).
A user is a plain map: id, email, name, slug, role
("owner" | "author"), bio, password_hash.
Summary
Functions
Change the password: the current one must match, the new one must be long enough.
Mint a session token for the user; store its hash. Returns the raw token.
Create a user. The email is unique (a transaction with the email item).
Remove a staff member (never the owner). Their posts stay, attributed to them.
A user without the password hash (for templates and the agent).
Mail a reset link if the address belongs to an author. Always :ok (no enumeration).
What a reset token is bound to: changes whenever the password does.
Set a new password from a reset link (Wraith.Tokens :password_reset).
Change a user's role (the caller's right to do so is the caller's business — Wraith.Policy).
Create the owner and mark setup done. Refused once any user exists — and
two setups submitted at once can't both win: the owner claim item is put
with :not_exists in the same transaction as the user.
Name, bio, avatar URL, website and social handles.
The user behind a session token, or nil.
Functions
Change the password: the current one must match, the new one must be long enough.
Mint a session token for the user; store its hash. Returns the raw token.
Create a user. The email is unique (a transaction with the email item).
Remove a staff member (never the owner). Their posts stay, attributed to them.
A user without the password hash (for templates and the agent).
Mail a reset link if the address belongs to an author. Always :ok (no enumeration).
What a reset token is bound to: changes whenever the password does.
Set a new password from a reset link (Wraith.Tokens :password_reset).
Change a user's role (the caller's right to do so is the caller's business — Wraith.Policy).
Create the owner and mark setup done. Refused once any user exists — and
two setups submitted at once can't both win: the owner claim item is put
with :not_exists in the same transaction as the user.
Name, bio, avatar URL, website and social handles.
The user behind a session token, or nil.
social_fields()