read password from env

This commit is contained in:
Thomas Ruoff
2020-11-24 00:09:41 +01:00
parent 4db3eadaeb
commit e929a6a1f3

View File

@@ -1,3 +1,5 @@
const ADMIN_PASSWORD = process.env.ADMIN_PASSWORD
export function authenticateAdmin({
username,
password,
@@ -9,8 +11,11 @@ export function authenticateAdmin({
return false
}
// FIXME: move at least to env variable
if (password !== 'secret') {
if (!ADMIN_PASSWORD) {
throw new Error('ADMIN_PASSWORD not set. Login disabled!')
}
if (password !== ADMIN_PASSWORD) {
return false
}