You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
34 lines
686 B
34 lines
686 B
import React from "react";
|
|
import { withIronSession } from "next-iron-session";
|
|
|
|
const PrivatePage = ({ user }) => (
|
|
<div>
|
|
<h1>Hello {user.email}</h1>
|
|
<p>Secret things live here...</p>
|
|
</div>
|
|
);
|
|
|
|
export const getServerSideProps = withIronSession(
|
|
async ({ req, res }) => {
|
|
const user = req.session.get("user");
|
|
|
|
if (!user) {
|
|
res.statusCode = 404;
|
|
res.end();
|
|
return { props: {} };
|
|
}
|
|
|
|
return {
|
|
props: { user }
|
|
};
|
|
},
|
|
{
|
|
cookieName: "MYSITECOOKIE",
|
|
cookieOptions: {
|
|
secure: process.env.NODE_ENV === "production" ? true : false
|
|
},
|
|
password: process.env.APPLICATION_SECRET
|
|
}
|
|
);
|
|
|
|
export default PrivatePage;
|
|
|