Files
sqlpage--sqlpage/examples/official-site/sqlpage/migrations/44_authentication_example.sql
lovasoa a128ad05f8 add an authentication example
update documentation
2024-06-21 21:19:12 +02:00

18 lines
698 B
SQL

create table users (
username text primary key,
password_hash text not null,
role text not null
);
-- Create example users with trivial passwords for the website's demo
insert into users (username, password_hash, role)
values
('admin', '$argon2i$v=19$m=8,t=1,p=1$YWFhYWFhYWE$ROyXNhK0utkzTA', 'admin'), -- password: admin
('user', '$argon2i$v=19$m=8,t=1,p=1$YWFhYWFhYWE$qsrWdjgl96ooYw', 'user'); -- password: user
-- (the password hashes can be generated using the `sqlpage.hash_password` function)
create table user_sessions (
session_token text primary key,
username text not null references users(username),
created_at timestamp not null default current_timestamp
);