Skip to content

Commit

Permalink
fix : login configuration use dotenv
Browse files Browse the repository at this point in the history
  • Loading branch information
qfdk committed Mar 2, 2024
1 parent f012bde commit 0f460c8
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 9 deletions.
2 changes: 2 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require('dotenv').config();

const express = require('express');
const path = require('path');
const bodyParser = require('body-parser');
Expand Down
4 changes: 0 additions & 4 deletions config.js

This file was deleted.

6 changes: 2 additions & 4 deletions middlewares/security.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
const config = require('../config');

const checkUser = (req, res, next) => {
res.locals.isLogin = false;
if (req.session.isLogin) {
res.locals.isLogin = true;
next();
} else {
const username = config.username,
password = config.password;
const username = process.env.EDW_USERNAME,
password = process.env.EDW_PASSWORD;
if (req.body.username === username && req.body.password === password) {
req.session.isLogin = true;
res.redirect('/');
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"express-session": "^1.17.1",
"express-status-monitor": "^1.2.8",
"serve-favicon": "^2.4.5",
"socket.io": "2.4.1"
"socket.io": "2.4.1",
"dotenv": "^16.4.5"
},
"devDependencies": {
"nodemon": "^3.0.3"
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ dockerode@^4.0.2:
docker-modem "^5.0.3"
tar-fs "~2.0.1"

dotenv@^16.4.5:
version "16.4.5"
resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.4.5.tgz#cdd3b3b604cb327e286b4762e13502f717cb099f"
integrity sha512-ZmdL2rui+eB2YwhsWzjInR8LldtZHGDoQ1ugH85ppHKwpUHL7j7rN0Ti9NCnGiQbhaZ11FpR+7ao1dNsmduNUg==

[email protected]:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"
Expand Down

0 comments on commit 0f460c8

Please sign in to comment.