fix and cleanup

This commit is contained in:
Joonas 2023-01-18 20:38:08 +02:00
parent 74fe12ce1f
commit 7df3c61f08
3 changed files with 10 additions and 14 deletions

View File

@ -1,9 +0,0 @@
import { createCookie } from "@remix-run/node";
export const OAuthToken = createCookie("token", {
domain: "http://localhost:3000",
path: "/",
maxAge: 604_800,
httpOnly: true,
secrets: [process.env.COOKIE_SECRET],
});

View File

@ -4,6 +4,7 @@ import { Link, useLoaderData } from "@remix-run/react";
import { prisma } from "~/db.server";
import { Form } from "@remix-run/react";
import { json } from "@remix-run/node";
import { redirect } from "@remix-run/node";
const countys = [
"Ahvenanmaa",
@ -62,9 +63,7 @@ export async function action({ request }) {
},
});
return countySubmit
? json(countySubmit)
: new Error("Something went wrong with creating the user");
return countySubmit;
}
export async function loader({ request }) {

View File

@ -1,9 +1,15 @@
import { OAuthToken } from "./cookies";
import { createCookieSessionStorage } from "@remix-run/node";
const { getSession, commitSession, destroySession } =
createCookieSessionStorage({
OAuthToken,
cookie: {
maxAge: 86400,
secrets: [process.env.COOKIE_SECRET],
path: "/",
secure: true,
httpOnly: true,
sameSite: "lax",
},
});
export { getSession, commitSession, destroySession };