From 3a893d202ee35660174e9a7850bcddbef4c6c9f7 Mon Sep 17 00:00:00 2001 From: Quentin ANIERE Date: Tue, 26 Apr 2022 22:27:56 +0200 Subject: [PATCH] Add password in .env --- .gitignore | 1 + index.js | 3 ++- package.json | 1 + yarn.lock | 5 +++++ 4 files changed, 9 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 2a0b79a..72aef9d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ node_modules *.pem docker-compose.yaml +.env diff --git a/index.js b/index.js index 97a88b8..3944ad5 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,6 @@ const fs = require("fs"); const https = require("https"); +const dotenv = require('dotenv').config(); const express = require("express"); const socketio = require("socket.io"); const sanitizeHtml = require("sanitize-html"); @@ -99,7 +100,7 @@ io.on("connection", (client) => { app.use(express.static("src")); -app.get("/clear", basicAuth({users:{"quentin": "BlanquerCaca89"}, challenge: true}), (req, res) => { +app.get("/clear", basicAuth({users:{"quentin": process.env.ADMIN_PASSWORD}, challenge: true}), (req, res) => { messagesHistory = []; res.send("message history was cleared"); io.sockets.emit("refresh"); diff --git a/package.json b/package.json index c21bb50..a5df40c 100644 --- a/package.json +++ b/package.json @@ -4,6 +4,7 @@ "main": "index.js", "license": "MIT", "dependencies": { + "dotenv": "^16.0.0", "express": "^4.17.3", "express-basic-auth": "^1.2.1", "sanitize-html": "^2.7.0", diff --git a/yarn.lock b/yarn.lock index ec4c62f..e59c341 100644 --- a/yarn.lock +++ b/yarn.lock @@ -206,6 +206,11 @@ domutils@^2.5.2: domelementtype "^2.2.0" domhandler "^4.2.0" +dotenv@^16.0.0: + version "16.0.0" + resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.0.tgz#c619001253be89ebb638d027b609c75c26e47411" + integrity sha512-qD9WU0MPM4SWLPJy/r2Be+2WgQj8plChsyrCNQzW/0WjvcJQiKQJ9mH3ZgB3fxbUUxgc/11ZJ0Fi5KiimWGz2Q== + ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d"