-
-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
馃敁 Add config to secure instance from unauth users (#559)
- Loading branch information
Showing
16 changed files
with
194 additions
and
104 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,9 +10,9 @@ declare global { | |
*/ | ||
NODE_ENV: "development" | "production"; | ||
/** | ||
* Can be "false" or a relative path eg. "/new" | ||
* Set to "true" to take users straight to app instead of landing page | ||
*/ | ||
LANDING_PAGE: string; | ||
DISABLE_LANDING_PAGE?: string; | ||
/** | ||
* Must be 32 characters long | ||
*/ | ||
|
@@ -57,6 +57,17 @@ declare global { | |
* Port number of the SMTP server | ||
*/ | ||
SMTP_PORT: string; | ||
/** | ||
* Comma separated list of email addresses that are allowed to register and login. | ||
* If not set, all emails are allowed. Wildcard characters are supported. | ||
* | ||
* Example: "[email protected], *@example.com, *@*.example.com" | ||
*/ | ||
ALLOWED_EMAILS?: string; | ||
/** | ||
* "true" to require authentication for creating new polls and accessing admin pages | ||
*/ | ||
AUTH_REQUIRED?: string; | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -39,6 +39,7 @@ | |
"editDetails": "Edit details", | ||
"editOptions": "Edit options", | ||
"email": "Email", | ||
"emailNotAllowed": "This email is not allowed.", | ||
"emailPlaceholder": "[email protected]", | ||
"endingGuestSessionNotice": "Once a guest session ends it cannot be resumed. You will not be able to edit any votes or comments you've made with this session.", | ||
"endSession": "End session", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,20 @@ | ||
import { GetServerSideProps } from "next"; | ||
import { serverSideTranslations } from "next-i18next/serverSideTranslations"; | ||
|
||
import Home from "@/components/home"; | ||
import { composeGetServerSideProps } from "@/utils/auth"; | ||
import { withPageTranslations } from "@/utils/with-page-translations"; | ||
|
||
export default function Page() { | ||
return <Home />; | ||
} | ||
|
||
export const getServerSideProps: GetServerSideProps = async ({ | ||
locale = "en", | ||
}) => { | ||
if (process.env.LANDING_PAGE) { | ||
if (process.env.LANDING_PAGE === "false") { | ||
return { | ||
redirect: { | ||
destination: "/new", | ||
permanent: false, | ||
}, | ||
}; | ||
export const getServerSideProps: GetServerSideProps = composeGetServerSideProps( | ||
async () => { | ||
// TODO (Luke Vella) [2023-03-14]: Remove this once we split the app from the landing page | ||
if (process.env.DISABLE_LANDING_PAGE === "true") { | ||
return { notFound: true }; | ||
} | ||
// if starts with /, it's a relative path | ||
if (process.env.LANDING_PAGE.startsWith("/")) { | ||
return { | ||
redirect: { | ||
destination: process.env.LANDING_PAGE, | ||
permanent: false, | ||
}, | ||
}; | ||
} | ||
} | ||
return { | ||
props: { | ||
...(await serverSideTranslations(locale, ["common", "homepage"])), | ||
}, | ||
}; | ||
}; | ||
return { props: {} }; | ||
}, | ||
withPageTranslations(["common", "homepage"]), | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.