user update

This commit is contained in:
JMARyA 2024-12-27 03:56:27 +01:00
parent d7a55f6579
commit e5fe40e4be
Signed by: jmarya
GPG key ID: 901B2ADDF27C2263
8 changed files with 205 additions and 77 deletions

View file

@ -9,24 +9,7 @@ Based is a micro framework providing web dev primitives.
- Templates (Shell)
## User Auth
To use the user auth feature, make sure a migration has added the following to your PostgresDB:
```sql
CREATE TYPE user_role AS ENUM ('regular', 'admin');
CREATE TABLE IF NOT EXISTS users (
username VARCHAR(255) NOT NULL PRIMARY KEY,
"password" text NOT NULL,
user_role user_role NOT NULL DEFAULT 'regular'
);
CREATE TABLE IF NOT EXISTS user_session (
id UUID NOT NULL PRIMARY KEY DEFAULT gen_random_uuid(),
token text NOT NULL,
"user" varchar(255) NOT NULL,
FOREIGN KEY("user") REFERENCES users(username)
);
```
To use the user auth feature, make sure a migration has added [these tables](src/auth/auth.sql) to your PostgresDB:
## HTMX
Based has a route for serving HTMX at `based::htmx::htmx_script_route` which you can include in your rocket `routes!`. The HTMX script will be available at `/assets/htmx.min.js`.