Fully tested the remote database

Added configurable hostname for default account email
This commit is contained in:
2024-05-03 09:26:12 +10:00
parent 6859b36ae0
commit 0bc7cb11f0
6 changed files with 13 additions and 9 deletions
+3 -4
View File
@@ -7,7 +7,7 @@ module.exports = async () => {
await sequelize.sync(); //this whole file is just one big BUGFIX
//validate env variables
if (!process.env.ADMIN_DEFAULT_USERNAME || !process.env.ADMIN_DEFAULT_PASSWORD) {
if (!process.env.ADMIN_DEFAULT_USERNAME || !process.env.ADMIN_DEFAULT_HOSTNAME || !process.env.ADMIN_DEFAULT_PASSWORD) {
//skip this if arguments are missing
return;
}
@@ -25,9 +25,8 @@ module.exports = async () => {
});
if (adminRecord == null) {
const webAddress = process.env.WEB_ADDRESS == 'localhost:3000' ? 'example.com' : process.env.WEB_ADDRESS; //can't log in as "localhost"
await accounts.create({
email: `${process.env.ADMIN_DEFAULT_USERNAME}@${webAddress}`,
email: `${process.env.ADMIN_DEFAULT_USERNAME}@${process.env.ADMIN_DEFAULT_HOSTNAME}`,
username: `${process.env.ADMIN_DEFAULT_USERNAME}`,
hash: await bcrypt.hash(`${process.env.ADMIN_DEFAULT_PASSWORD}`, await bcrypt.genSalt(11)),
type: 'normal',
@@ -35,6 +34,6 @@ module.exports = async () => {
mod: true
});
console.warn(`Created default admin account (email: ${process.env.ADMIN_DEFAULT_USERNAME}@${webAddress}; password: ${process.env.ADMIN_DEFAULT_PASSWORD})`);
console.warn(`Created default admin account (email: ${process.env.ADMIN_DEFAULT_USERNAME}@${process.env.ADMIN_DEFAULT_HOSTNAME}; password: ${process.env.ADMIN_DEFAULT_PASSWORD})`);
}
};