Ensure accounts have a created_at date.
This commit is contained in:
parent
bb1a472d19
commit
b50aa7814e
4 changed files with 35 additions and 4 deletions
|
@ -2,6 +2,6 @@
|
|||
|
||||
## Creating your first account
|
||||
|
||||
```node ./create_account.js USERNAME EMAIL_ADDRESS $(mkpasswd -m bcrypt)```
|
||||
```node ./bin/create_account.js USERNAME EMAIL_ADDRESS $(mkpasswd -m bcrypt)```
|
||||
|
||||
For the provided password prompt, enter your chosen password.
|
|
@ -39,11 +39,11 @@ module.exports = {
|
|||
},
|
||||
|
||||
getAccountByUsername: (username) => {
|
||||
return db.prepare("SELECT id, username, email, password_hash, account_tier FROM accounts WHERE username = ?").get(username);
|
||||
return db.prepare("SELECT id, username, email, password_hash, account_tier, created_at FROM accounts WHERE username = ?").get(username);
|
||||
},
|
||||
|
||||
createAccount: (username, email, password_hash) => {
|
||||
db.prepare("INSERT INTO accounts (username, email, password_hash, account_tier) VALUES (?, ?, ?, 0)").run(username, email, password_hash);
|
||||
db.prepare("INSERT INTO accounts (username, email, password_hash, account_tier, created_at) VALUES (?, ?, ?, 0)").run(username, email, password_hash, Date.now());
|
||||
},
|
||||
|
||||
checkAuthCookie: (cookie_value) => {
|
||||
|
@ -122,7 +122,7 @@ module.exports = {
|
|||
},
|
||||
|
||||
getAccountByToken: (token) => {
|
||||
return db.prepare("SELECT id, username, email, password_hash, account_tier FROM accounts WHERE id IN (SELECT user_id FROM oauth_tokens WHERE token = ?)").get(token);
|
||||
return db.prepare("SELECT id, username, email, password_hash, account_tier, created_at FROM accounts WHERE id IN (SELECT user_id FROM oauth_tokens WHERE token = ?)").get(token);
|
||||
},
|
||||
|
||||
getAccountActivityByAccount: (user_id) => {
|
||||
|
|
30
migrations/20231120012518-accountCreatedAtColumn.js
Normal file
30
migrations/20231120012518-accountCreatedAtColumn.js
Normal file
|
@ -0,0 +1,30 @@
|
|||
"use strict";
|
||||
|
||||
let dbm;
|
||||
let type;
|
||||
let seed;
|
||||
|
||||
/**
|
||||
* We receive the dbmigrate dependency from dbmigrate initially.
|
||||
* This enables us to not have to rely on NODE_PATH.
|
||||
*/
|
||||
exports.setup = function (options, seedLink) {
|
||||
dbm = options.dbmigrate;
|
||||
type = dbm.dataType;
|
||||
seed = seedLink;
|
||||
};
|
||||
|
||||
exports.up = function (db) {
|
||||
return db.addColumn("accounts", "created_at", {
|
||||
type: "string",
|
||||
default: Date.now(),
|
||||
});
|
||||
};
|
||||
|
||||
exports.down = function (db) {
|
||||
return db.removeColumn("accounts", "created_at");
|
||||
};
|
||||
|
||||
exports._meta = {
|
||||
version: 1,
|
||||
};
|
|
@ -85,6 +85,7 @@ module.exports = {
|
|||
"@id": `https://${req.headers.host}/@${account.username}`,
|
||||
},
|
||||
};
|
||||
console.log(account.created_at);
|
||||
databaseHandler.addActivity(JSON.stringify(accountActivity), accountActivity["@type"], true, accountActivity["@id"], account.username, (new Date(account.created_at)).toISOString());
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue