Move authentication logic

This commit is contained in:
Kalle
2022-05-19 17:34:40 +03:00
parent fea8b189a7
commit 125dac42fa
8 changed files with 12 additions and 6 deletions

View File

@@ -14,13 +14,13 @@ import {
Scripts,
ScrollRestoration,
} from "@remix-run/react";
import { authenticator } from "~/core/authenticator.server";
import { authenticator } from "~/core/auth/authenticator.server";
import globalStyles from "~/styles/global.css";
import layoutStyles from "~/styles/layout.css";
import resetStyles from "~/styles/reset.css";
import commonStyles from "~/styles/common.css";
import { Layout } from "./components/layout";
import type { LoggedInUser } from "./core/DiscordStrategy.server";
import type { LoggedInUser } from "~/core/auth/DiscordStrategy.server";
export const unstable_shouldReload: ShouldReloadFunction = () => false;

View File

@@ -1,4 +1,7 @@
import { authenticator, DISCORD_AUTH_KEY } from "~/core/authenticator.server";
import {
authenticator,
DISCORD_AUTH_KEY,
} from "~/core/auth/authenticator.server";
import type { LoaderFunction } from "@remix-run/node";
import { redirect } from "@remix-run/node";
import { userPage } from "~/utils/urls";

View File

@@ -1,4 +1,7 @@
import { authenticator, DISCORD_AUTH_KEY } from "~/core/authenticator.server";
import {
authenticator,
DISCORD_AUTH_KEY,
} from "~/core/auth/authenticator.server";
import type { ActionFunction } from "@remix-run/node";
export const action: ActionFunction = async ({ request }) => {

View File

@@ -1,5 +1,5 @@
import type { ActionFunction } from "@remix-run/node";
import { authenticator } from "~/core/authenticator.server";
import { authenticator } from "~/core/auth/authenticator.server";
export const action: ActionFunction = async ({ request }) => {
await authenticator.logout(request, { redirectTo: "/" });

View File

@@ -1,5 +1,5 @@
import { z } from "zod";
import { authenticator } from "~/core/authenticator.server";
import { authenticator } from "~/core/auth/authenticator.server";
export function notFoundIfFalsy<T>(value: T | null | undefined): T {
if (!value) throw new Response(null, { status: 404 });