Better naming, start on temp tokens table, etc.

This commit is contained in:
Bryan Ashby 2019-06-11 18:25:24 -06:00
parent 29e0c8f790
commit 4158b07ad0
No known key found for this signature in database
GPG key ID: B49EB437951D2542
4 changed files with 119 additions and 19 deletions

View file

@ -203,6 +203,22 @@ const DB_INIT_TABLE = {
);`
);
//
// Table for temporary tokens, generally used for e.g. 'outside'
// access such as email links.
// Examples: PW reset, enabling of 2FA/OTP, etc.
//
dbs.user.run(
`CREATE TABLE IF NOT EXISTS user_temporary_token (
user_id INTEGER NOT NULL,
token VARCHAR NOT NULL,
timestamp DATETIME NOT NULL,
purpose VARCHAR NOT NULL,
UNIQUE(user_id, token),
FOREIGN KEY(user_id) REFERENCES user(id) ON DELETE CASCADE
);`
);
return cb(null);
},