From 9c7548625b636db9e0af7638be4bfd407f93a24c Mon Sep 17 00:00:00 2001 From: Guusvanmeerveld Date: Tue, 14 Feb 2023 11:42:39 +0100 Subject: [PATCH] Fix login options not dynamically reading ALLOW_REGISTRATION --- .env | 2 +- src/pages/blog/login.tsx | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/.env b/.env index d89c8ba..fea3a81 100644 --- a/.env +++ b/.env @@ -1,4 +1,4 @@ NEXT_PUBLIC_GITEA_USERNAME=Guusvanmeerveld NEXT_PUBLIC_GITEA_SERVER=git.guusvanmeerveld.dev DATABASE_URL=postgresql://portfolio:portfolio@localhost:5432/portfolio?schema=public -# ALLOW_REGISTRATION=true \ No newline at end of file +# NEXT_PUBLIC_ALLOW_REGISTRATION=true \ No newline at end of file diff --git a/src/pages/blog/login.tsx b/src/pages/blog/login.tsx index 35150f0..22674da 100644 --- a/src/pages/blog/login.tsx +++ b/src/pages/blog/login.tsx @@ -1,4 +1,4 @@ -import { GetStaticProps, NextPage } from "next"; +import { GetServerSideProps, NextPage } from "next"; import { NextSeo } from "next-seo"; import Layout from "@components/Layout"; @@ -8,7 +8,9 @@ import multipleClassNames from "@utils/multipleClassNames"; import styles from "./login.module.scss"; import { registrationIsEnabled } from "@utils/config"; -const Login: NextPage = () => { +const Login: NextPage<{ registrationEnabled: boolean }> = ({ + registrationEnabled +}) => { return ( @@ -16,7 +18,7 @@ const Login: NextPage = () => {

Login to blog

@@ -61,7 +63,7 @@ const Login: NextPage = () => {
- {registrationIsEnabled && ( + {registrationEnabled && ( <>
{ ); }; +export const getServerSideProps: GetServerSideProps = async () => { + return { props: { registrationEnabled: registrationIsEnabled } }; +}; + export default Login;