Skip to content

Commit

Permalink
Prevent sessions.ts from being send to client
Browse files Browse the repository at this point in the history
I don't think this happened so far but changing it to .server.ts ensures that it will not happen.
  • Loading branch information
malte-laukoetter committed Dec 20, 2023
1 parent ae45fe9 commit 07746eb
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 16 deletions.
2 changes: 1 addition & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fileignoreconfig:
allowed_patterns: [key]
- filename: tests/e2e/LoginPage.ts
allowed_patterns: [password]
- filename: app/sessions.ts
- filename: app/sessions.server.ts
allowed_patterns: [sessionCookieSecret, SESSION_COOKIE_SECRET]

version: ""
Expand Down
2 changes: 1 addition & 1 deletion app/routes/_index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
type LoaderFunctionArgs,
type MetaFunction,
} from "@remix-run/node";
import { isSessionValid } from "~/sessions";
import { isSessionValid } from "~/sessions.server";

export const meta: MetaFunction = () => {
return [
Expand Down
2 changes: 1 addition & 1 deletion app/routes/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
import { Form, useActionData, useNavigation } from "@remix-run/react";
import TroiApiService, { AuthenticationFailed } from "troi-library";
import { LoadingOverlay } from "~/components/LoadingOverlay";
import { commitSession, getSession } from "~/sessions";
import { commitSession, getSession } from "~/sessions.server";

export const meta: MetaFunction = () => {
return [
Expand Down
2 changes: 1 addition & 1 deletion app/routes/logout.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ActionFunctionArgs, redirect } from "@remix-run/node";
import { destroySession, getSession } from "~/sessions";
import { destroySession, getSession } from "~/sessions.server";

export async function action({ request }: ActionFunctionArgs) {
const session = await getSession(request.headers.get("Cookie"));
Expand Down
2 changes: 1 addition & 1 deletion app/routes/phases.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { LoaderFunctionArgs, json, redirect } from "@remix-run/node";
import { isSessionValid } from "~/sessions";
import { isSessionValid } from "~/sessions.server";
import { loadPhases } from "~/tasks/TrackyPhase";
import { getCalculationPositions } from "~/troi/troiApiController";

Expand Down
2 changes: 1 addition & 1 deletion app/routes/projects.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
getCalendarEvents,
getTimeEntries,
} from "~/troi/troiApiController";
import { getSession, isSessionValid } from "~/sessions";
import { getSession, isSessionValid } from "~/sessions.server";
import { loadTasks } from "~/tasks/TrackyTask";
import { AuthenticationFailed } from "troi-library";

Expand Down
2 changes: 1 addition & 1 deletion app/routes/time_entries.$id.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ActionFunctionArgs, redirect } from "@remix-run/node";
import { AuthenticationFailed } from "troi-library";
import { isSessionValid } from "~/sessions";
import { isSessionValid } from "~/sessions.server";
import { deleteTimeEntry, updateTimeEntry } from "~/troi/troiApiController";

export async function action({ request, params }: ActionFunctionArgs) {
Expand Down
2 changes: 1 addition & 1 deletion app/routes/time_entries.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ActionFunctionArgs, redirect } from "@remix-run/node";
import { AuthenticationFailed } from "troi-library";
import { isSessionValid } from "~/sessions";
import { isSessionValid } from "~/sessions.server";
import { addTimeEntry } from "~/troi/troiApiController";

export async function action({ request, params }: ActionFunctionArgs) {
Expand Down
6 changes: 0 additions & 6 deletions app/sessions.ts → app/sessions.server.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import type { CalendarEvent } from "troi-library";

// how to invalidate:
// 1. shortish ttl for session-cookie
// 2. revalidate after request was send (stale-while-revalidate)

// split login & troi data sessions in two and add a ttl to the session data cookie? or save it as a session cookie?

import { createCookie, createFileSessionStorage } from "@remix-run/node";
import type { TimeEntries } from "./troi/TimeEntry";
import type { CalculationPosition } from "./troi/CalculationPosition";
Expand Down
4 changes: 2 additions & 2 deletions app/troi/troiApiController.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import type { CalendarEvent } from "troi-library";
import TroiApiService, { AuthenticationFailed } from "troi-library";
import type { SessionData } from "~/sessions";
import { commitSession, destroySession, getSession } from "~/sessions";
import type { SessionData } from "~/sessions.server";
import { commitSession, destroySession, getSession } from "~/sessions.server";
import { addDaysToDate, formatDateToYYYYMMDD } from "~/utils/dateUtils";
import type { TimeEntries, TimeEntry } from "./TimeEntry";
import type { CalculationPosition } from "./CalculationPosition";
Expand Down

0 comments on commit 07746eb

Please sign in to comment.