Sign up method.

beginning of adding methods to create account and authentication.
This commit is contained in:
Greg Burri 2022-11-22 01:13:19 +01:00
parent 855eb16973
commit 5e4e086247
5 changed files with 258 additions and 32 deletions

View file

@ -8,16 +8,38 @@ CREATE TABLE [Version] (
CREATE TABLE [User] (
[id] INTEGER PRIMARY KEY,
[email] TEXT NOT NULL,
[password] TEXT NOT NULL, -- Hashed and salted.
[name] TEXT NOT NULL
[name] TEXT,
[default_servings] INTEGER DEFAULT 4,
[password] TEXT NOT NULL, -- argon2(password_plain, salt).
[creation_datetime] DATETIME NOT NULL, -- Updated when the validation email is sent.
[validation_token] TEXT -- If not null then the user has not validated his account yet.
);
CREATE UNIQUE INDEX [User_email_index] ON [User] ([email]);
CREATE TABLE [UserLoginToken] (
[id] INTEGER PRIMARY KEY,
[user_id] INTEGER NOT NULL,
[last_login_datetime] DATETIME,
[token] TEXT NOT NULL, -- 24 alphanumeric character token. Can be stored in a cookie to be able to authenticate without a password.
[ip] INTEGER,
[user_agent] TEXT,
FOREIGN KEY([user_id]) REFERENCES [User]([id])
);
CREATE INDEX [UserLoginToken_token_index] ON [UserLoginToken] ([token]);
CREATE TABLE [Recipe] (
[id] INTEGER PRIMARY KEY,
[user_id] INTEGER NOT NULL,
[title] TEXT NOT NULL,
[estimate_time] INTEGER,
[description] TEXT,
[servings] INTEGER DEFAULT 4,
FOREIGN KEY([user_id]) REFERENCES [User]([id])
);