diff --git a/.env.development b/.env.development
index eab70aa3..22959372 100644
--- a/.env.development
+++ b/.env.development
@@ -1,5 +1,6 @@
NEXT_PUBLIC_GRAPHQL_URI="http://localhost:3001/graphql"
-MONGO_URI="mongodb+srv://johnDoe:T74OcxqL15TRt7Zn@lbke-demo-ara2d.mongodb.net/sample_restaurants?retryWrites=true&w=majority"
APOLLO_SERVER_CORS_WHITELIST="http://localhost:3000"
ADMIN_EMAIL="you.need.to.change.this.value@vulcanjs.com"
-ADMIN_INITIAL_PASSWORD="vulcan_is_cool"
\ No newline at end of file
+ADMIN_INITIAL_PASSWORD="vulcan_is_cool"
+MONGO_URI="mongodb+srv://johnDoe:T74OcxqL15TRt7Zn@lbke-demo-ara2d.mongodb.net/sample_restaurants?retryWrites=true&w=majority"
+# MONGO_URI="mongodb://localhost:27017/vulcan-next-app"
\ No newline at end of file
diff --git a/cypress/integration/vns/private.spec.ts b/cypress/integration/vns/private.spec.ts
index f8c581e9..4d185e21 100644
--- a/cypress/integration/vns/private.spec.ts
+++ b/cypress/integration/vns/private.spec.ts
@@ -1,3 +1,9 @@
+/**
+ * NOTE: this tests cover the "withPrivateAccess" hook
+ * which can be considered as deprecated
+ *
+ * See "auth.spec.ts" for a more recent test
+ */
describe("private pages", () => {
describe("server side", () => {
it("redirects when accessing private page", () => {
diff --git a/next.config.js b/next.config.js
index d7497214..0f05a6f4 100644
--- a/next.config.js
+++ b/next.config.js
@@ -58,9 +58,14 @@ module.exports = (phase, { defaultConfig }) => {
let extendedConfig;
extendedConfig = extendNextConfig(defaultConfig);
- extendedConfig.env = {};
- extendedConfig.serverRuntimeConfig = {};
- extendedConfig.publicRuntimeConfig = {};
+ extendedConfig.env = {
+ NEXT_PUBLIC_IS_USING_DEMO_DATABASE: !!(process.env.MONGO_URI || "").match(
+ /lbke\-demo/
+ ),
+ NEXT_PUBLIC_IS_USING_LOCAL_DATABSE: !!(process.env.MONGO_URI || "").match(
+ /localhost/
+ ),
+ };
// Enable Webpack analyzer
if (process.env.ANALYZE && process.env.ANALYZE !== "false") {
diff --git a/src/components/home/home.tsx b/src/components/home/home.tsx
index 899eaa23..cda0e07f 100644
--- a/src/components/home/home.tsx
+++ b/src/components/home/home.tsx
@@ -4,13 +4,33 @@ import { Typography } from "@material-ui/core";
export const Home = () => (
-
-
- Below, find Vulcan Next Readme loaded from an MD file using{" "}
- MDXJS
-
-
+
+
+ Hi there! You are running Vulcan Next! You are doing great so far.
+
+
+ Below, find Vulcan Next Readme loaded from a markdown file using{" "}
+ MDXJS.
+
+
+ You can also read the rest of{" "}
+ Vulcan documentation here.
+
+
Have fun!
+
+
);
diff --git a/src/components/layout/MDXMuiLayout.tsx b/src/components/layout/MDXMuiLayout.tsx
index 89d9c966..26aa7f16 100644
--- a/src/components/layout/MDXMuiLayout.tsx
+++ b/src/components/layout/MDXMuiLayout.tsx
@@ -47,7 +47,8 @@ const components = {
//inlineCode: Typography,
//hr: Typography,
a: Link,
- //img: Typography,
+ // TODO: didn't find a way to override image styling...
+ img: (props) =>
,
};
const MDXMuiLayout = ({ children }: MDXLayoutProps) => {
return (
diff --git a/src/components/user/form.js b/src/components/user/form.tsx
similarity index 100%
rename from src/components/user/form.js
rename to src/components/user/form.tsx
diff --git a/src/components/user/layout.js b/src/components/user/layout.tsx
similarity index 56%
rename from src/components/user/layout.js
rename to src/components/user/layout.tsx
index e5577252..c5ba56e9 100644
--- a/src/components/user/layout.js
+++ b/src/components/user/layout.tsx
@@ -1,14 +1,28 @@
import Head from "next/head";
-import Footer from "~/components/layout/Footer";
const Layout = (props) => (
<>
- With Cookies
+ Auth
- {props.children}
+
+ {process.env.NEXT_PUBLIC_IS_USING_DEMO_DATABASE ? (
+
+
You are using LBKE read-only demo database.
+
+ To enable authentication features, please setup your own local
+ database.
+
+
+ See home README for relevant instructions.
+
+
+ ) : (
+ props.children
+ )}
+
{/**/}
diff --git a/src/pages/api/signup.ts b/src/pages/api/signup.ts
index 49c05c0c..9344673e 100644
--- a/src/pages/api/signup.ts
+++ b/src/pages/api/signup.ts
@@ -14,7 +14,7 @@ export default async function signup(
// we need to use it to ensure that we run all callbacks associated to the user collection
const user = req.body;
// TODO: check if this is ok to compute the context from a NextApiRequest like this
- const context = await contextFromReq(req as unknown as Request)
+ const context = await contextFromReq((req as unknown) as Request);
await createMutator({ model: User, data: user, context });
res.status(200).send({ done: true });
} catch (error) {
diff --git a/src/pages/docs/features.md b/src/pages/docs/features.md
index 728bdd1f..6af6b5c5 100644
--- a/src/pages/docs/features.md
+++ b/src/pages/docs/features.md
@@ -47,9 +47,15 @@ It will run an ephemeral Docker instance of Mongo v4. Data are stored in your pr
## Authentication
-### Demonstration of redirection
+### Passport authentication
-See `src/pages/vns/debug/private`. You can use `withPrivateAccess` HOC to make a page private and handle redirections correctly in all situations (server-side, client-side, in the context of a static export etc.).
+Access the See the home page footer to access signup, login, logout and profile page. Implementation is based on Next official example [with Passport and Next Connect](https://github.com/vercel/next.js/tree/canary/examples/with-passport-and-next-connect)
+
+### Experimental SSR redirection
+
+*This feature is experimental and not useful in most scenarios.* We advise to stick to client-side only patterns. [See relevant issue](https://github.com/VulcanJS/vulcan-next/issues/71).
+
+See `src/pages/vns/debug/private` for a demo. You can use `withPrivateAccess` HOC to make a page private and handle redirections correctly in all situations (server-side, client-side, in the context of a static export etc.).
## Apollo Server
diff --git a/src/pages/index.tsx b/src/pages/index.tsx
index f9d8bf02..b0d664b0 100644
--- a/src/pages/index.tsx
+++ b/src/pages/index.tsx
@@ -1,39 +1,8 @@
-import { useQuery /*, useMutation*/ } from "@apollo/client";
-import gql from "graphql-tag";
import Home from "~/components/home";
//import { useForm } from "react-hook-form";
import MDXMuiLayout from "~/components/layout/MDXMuiLayout";
const HomePage = () => {
- const vulcanSiteDataQuery = gql`
- query getSiteData {
- siteData {
- url
- title
- sourceVersion
- logoUrl
- }
- }
- `;
-
- const { data, loading, error } = useQuery(vulcanSiteDataQuery);
-
- let content;
- if (loading) {
- content = `Connecting to your graphQL backend...`; // on ${client.name}`
- } else if (error) {
- if (error.networkError?.message === "Failed to fetch") {
- content = `No graphQL backend is running.`;
- } else {
- content = `Couldn't connect to your graphQL backend (${error}).`;
- }
- } else if (data) {
- content = `Successfully connected to your graphQL backend.\n Data: ${JSON.stringify(
- data,
- null,
- 4
- )}`;
- }
return (
diff --git a/src/pages/vns/debug/meteor.tsx b/src/pages/vns/debug/meteor.tsx
new file mode 100644
index 00000000..81a53590
--- /dev/null
+++ b/src/pages/vns/debug/meteor.tsx
@@ -0,0 +1,40 @@
+/**
+ * Demo queries to a legacy Vulcan Meteor backend
+ */
+import { useQuery /*, useMutation*/ } from "@apollo/client";
+import gql from "graphql-tag";
+
+const VulcanMeteorDemo = () => {
+ const vulcanSiteDataQuery = gql`
+ query getSiteData {
+ siteData {
+ url
+ title
+ sourceVersion
+ logoUrl
+ }
+ }
+ `;
+
+ const { data, loading, error } = useQuery(vulcanSiteDataQuery);
+
+ let content;
+ if (loading) {
+ content = `Connecting to your graphQL backend...`; // on ${client.name}`
+ } else if (error) {
+ if (error.networkError?.message === "Failed to fetch") {
+ content = `No graphQL backend is running.`;
+ } else {
+ content = `Couldn't connect to your graphQL backend (${error}).`;
+ }
+ } else if (data) {
+ content = `Successfully connected to your graphQL backend.\n Data: ${JSON.stringify(
+ data,
+ null,
+ 4
+ )}`;
+ }
+ return content;
+};
+
+export default VulcanMeteorDemo;