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.
29 lines
747 B
29 lines
747 B
import { withIronSessionApiRoute } from "iron-session/next";
|
|
|
|
const VALID_EMAIL = "chris@decimal.fm";
|
|
const VALID_PASSWORD = "opensesame";
|
|
|
|
export default withIronSessionApiRoute(
|
|
async (req, res) => {
|
|
if (req.method === "POST") {
|
|
const { email, password } = req.body;
|
|
|
|
if (email === VALID_EMAIL && password === VALID_PASSWORD) {
|
|
req.session.set("user", { email });
|
|
await req.session.save();
|
|
return res.status(201).send("");
|
|
}
|
|
|
|
return res.status(403).send("");
|
|
}
|
|
|
|
return res.status(404).send("");
|
|
},
|
|
{
|
|
cookieName: "MYSITECOOKIE",
|
|
cookieOptions: {
|
|
secure: process.env.NODE_ENV === "production" ? true : false
|
|
},
|
|
password: process.env.APPLICATION_SECRET
|
|
}
|
|
);
|
|
|