From 5a5a278d9e3a65f404f12967e3d5dde9e8f7fb05 Mon Sep 17 00:00:00 2001 From: Mike Cao Date: Wed, 22 Jun 2022 02:28:23 -0700 Subject: [PATCH] Removed DISABLE_LOGIN from middleware. --- next.config.js | 3 ++- pages/_middleware.js | 9 +-------- pages/login.js | 2 +- store/version.js | 2 +- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/next.config.js b/next.config.js index e458b8dc..9630e22e 100644 --- a/next.config.js +++ b/next.config.js @@ -3,7 +3,8 @@ const pkg = require('./package.json'); module.exports = { env: { - VERSION: pkg.version, + version: pkg.version, + loginDisabled: process.env.DISABLE_LOGIN, }, basePath: process.env.BASE_PATH, experimental: { diff --git a/pages/_middleware.js b/pages/_middleware.js index 256efb42..b8c66e94 100644 --- a/pages/_middleware.js +++ b/pages/_middleware.js @@ -15,13 +15,6 @@ function customScriptName(req) { } } -function disableLogin(req) { - console.log(process.env, process.env.DISABLE_LOGIN); - if (process.env.DISABLE_LOGIN && req.nextUrl.pathname.endsWith('/login')) { - return new Response('Login is disabled', { status: 403 }); - } -} - function forceSSL(req, res) { if (process.env.FORCE_SSL && req.nextUrl.protocol === 'http:') { res.headers.set('Strict-Transport-Security', 'max-age=31536000; includeSubDomains'); @@ -31,7 +24,7 @@ function forceSSL(req, res) { } export function middleware(req) { - const fns = [customScriptName, disableLogin]; + const fns = [customScriptName]; for (const fn of fns) { const res = fn(req); diff --git a/pages/login.js b/pages/login.js index d975e3c7..94c0df64 100644 --- a/pages/login.js +++ b/pages/login.js @@ -3,7 +3,7 @@ import Layout from 'components/layout/Layout'; import LoginForm from 'components/forms/LoginForm'; export default function LoginPage() { - if (process.env.DISABLE_LOGIN) { + if (process.env.loginDisabled) { return null; } diff --git a/store/version.js b/store/version.js index eacca340..5f74141c 100644 --- a/store/version.js +++ b/store/version.js @@ -7,7 +7,7 @@ import { getItem } from 'lib/web'; const REPO_URL = 'https://api.umami.is/v1/updates'; const initialState = { - current: process.env.VERSION, + current: process.env.version, latest: null, hasUpdate: false, };