Sign up method.
beginning of adding methods to create account and authentication.
This commit is contained in:
parent
855eb16973
commit
5e4e086247
5 changed files with 258 additions and 32 deletions
18
backend/sql/data_test.sql
Normal file
18
backend/sql/data_test.sql
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
INSERT INTO [User] ([id], [email], [name], [password], [creation_datetime], [validation_token])
|
||||
VALUES (
|
||||
1,
|
||||
'paul@test.org',
|
||||
'paul',
|
||||
'$argon2id$v=19$m=4096,t=3,p=1$1vtXcacYjUHZxMrN6b2Xng$wW8Z59MIoMcsIljnjHmxn3EBcc5ymEySZPUVXHlRxcY',
|
||||
0,
|
||||
NULL
|
||||
);
|
||||
|
||||
INSERT INTO [Recipe] ([user_id], [title])
|
||||
VALUES (1, 'Croissant au jambon');
|
||||
|
||||
INSERT INTO [Recipe] ([user_id], [title])
|
||||
VALUES (1, 'Gratin de thon aux olives');
|
||||
|
||||
INSERT INTO [Recipe] ([user_id], [title])
|
||||
VALUES (1, 'Saumon en croute');
|
||||
|
|
@ -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])
|
||||
);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue