Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion solid-start-v2/with-auth/src/auth/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,18 @@ export interface Session {
email: string;
}

const SESSION_COOKIE_NAME = "solid_start_auth_session";

export const getSession = () =>
useSession<Session>({
password: process.env.SESSION_SECRET ?? "default_password_which_should_be_long_enough"
name: SESSION_COOKIE_NAME,
password: process.env.SESSION_SECRET ?? "default_password_which_should_be_long_enough",
cookie: {
httpOnly: true,
path: "/",
sameSite: "lax",
secure: process.env.NODE_ENV === "production"
}
});

export async function createSession(user: Session, redirectTo?: string) {
Expand Down
11 changes: 10 additions & 1 deletion solid-start-v2/with-drizzle/src/api/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import { eq } from "drizzle-orm";
import { db } from "./db";
import { Users } from "../../drizzle/schema";

const SESSION_COOKIE_NAME = "solid_start_drizzle_session";

function validateUsername(username: unknown) {
if (typeof username !== "string" || username.length < 3) {
return `Usernames must be at least 3 characters long`;
Expand All @@ -31,7 +33,14 @@ async function register(username: string, password: string) {

function getSession() {
return useSession({
password: process.env.SESSION_SECRET ?? "areallylongsecretthatyoushouldreplace"
name: SESSION_COOKIE_NAME,
password: process.env.SESSION_SECRET ?? "areallylongsecretthatyoushouldreplace",
cookie: {
httpOnly: true,
path: "/",
sameSite: "lax",
secure: process.env.NODE_ENV === "production"
}
});
}

Expand Down
11 changes: 10 additions & 1 deletion solid-start-v2/with-prisma/src/lib/server.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { useSession } from "@solidjs/start/http";
import { db } from "./db";

const SESSION_COOKIE_NAME = "solid_start_prisma_session";

export function validateUsername(username: unknown) {
if (typeof username !== "string" || username.length < 3) {
return `Usernames must be at least 3 characters long`;
Expand Down Expand Up @@ -36,6 +38,13 @@ export async function register(username: string, password: string) {

export function getSession() {
return useSession({
password: process.env.SESSION_SECRET ?? "areallylongsecretthatyoushouldreplace"
name: SESSION_COOKIE_NAME,
password: process.env.SESSION_SECRET ?? "areallylongsecretthatyoushouldreplace",
cookie: {
httpOnly: true,
path: "/",
sameSite: "lax",
secure: process.env.NODE_ENV === "production"
}
});
}