Merge pull request #8 from jor3l/fix/welcome-2022

Fix/welcome 2022
pull/4/head
Adam Black 2022-03-03 03:50:17 +00:00 committed by GitHub
commit 927cf5bf18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 26 additions and 3 deletions

View File

@ -26,7 +26,7 @@ async function readJWT(token) {
async function signIn(email, password) {
let account = await orm.models.accounts.findOne({ where: { email } });
if (account.dataValues) {
if (account && account.dataValues) {
account = account.dataValues;
const inputPassword = crypto.createHash('sha256').update(password + process.env.APP_SALT).digest('hex');
if (account.password === inputPassword) {

View File

@ -16,6 +16,19 @@ export async function getAccountFromEmail(email) {
return null;
}
export async function createBaseAccount() {
await orm.models.accounts.create({
id: 0,
email: 'dummy@retropilot.org',
password: '123123',
created: Date.now(),
last_ping: Date.now(),
email_verify_token: 'notokenplease',
});
return { success: true, status: 200 };
}
export async function _dirtyCreateAccount(email, password, created, admin) {
logger.log('creating acount: ', email, password, created, admin);
return orm.models.accounts.create({
@ -87,6 +100,7 @@ export async function getAllUsers() {
export default {
createAccount,
createBaseAccount,
verifyEmailToken,
getAccountFromId,
getAllUsers,

View File

@ -17,7 +17,7 @@ server {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://server:3000;
}

View File

@ -2,6 +2,8 @@ version: "3.0"
services:
nginx:
image: nginx:1.15-alpine
depends_on:
- server
command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"
ports:
- "80:80"

View File

@ -11,7 +11,7 @@ export default (sequelize) => {
type: DataTypes.INTEGER,
},
identifier: {
allowNull: false,
allowNull: true,
type: DataTypes.TEXT,
},
dongle_id: {

View File

@ -6,6 +6,7 @@ import log4js from 'log4js';
import storageController from '../controllers/storage';
import deviceController from '../controllers/devices';
import authenticationController from './../controllers/authentication';
import userController from './../controllers/users';
const logger = log4js.getLogger('default');
const router = express.Router();

View File

@ -24,6 +24,12 @@ function runAsyncWrapper(callback) {
};
}
if(process.env.NODE_ENV === 'development') {
router.get('/useradmin/createbaseaccount', runAsyncWrapper(async (req, res) => {
res.send(await userController.createBaseAccount());
}));
}
router.post('/useradmin/auth', bodyParser.urlencoded({ extended: true }), runAsyncWrapper(async (req, res) => {
const signIn = await authenticationController.signIn(req.body.email, req.body.password);