Skip to content

Commit

Permalink
Refactor login.tsx: Remove unused imports and update fetcher types
Browse files Browse the repository at this point in the history
  • Loading branch information
Reynard-G committed Oct 7, 2024
1 parent 2e6c5b9 commit f218b16
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions app/routes/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@ import { SpokeSpinner } from "~/components/ui/spinner";
import { authenticator } from "~/lib/services/auth.server";
import { rateLimiter } from "~/lib/services/ratelimit.server";

type LoginFetcherResponse = {
error?: string;
};

export const meta: MetaFunction = () => {
return [
{ title: "Login • Divinity" },
Expand All @@ -39,7 +35,7 @@ export async function action({ request }: ActionFunctionArgs) {
const { success } = await rateLimiter.limit(identifier);

if (!success) {
return json<LoginFetcherResponse>(
return json(
{ error: "Too many login attempts. Please try again later." },
{ status: 429 },
);
Expand All @@ -52,15 +48,12 @@ export async function action({ request }: ActionFunctionArgs) {
});
} catch (error) {
if (error instanceof Response) throw error;
return json<LoginFetcherResponse>(
{ error: "Invalid username or password" },
{ status: 401 },
);
return json({ error: "Invalid username or password" }, { status: 401 });
}
}

export default function Login() {
const fetcher = useFetcher<LoginFetcherResponse>();
const fetcher = useFetcher<typeof action>();

const isSubmitting = fetcher.state === "submitting";

Expand Down

0 comments on commit f218b16

Please sign in to comment.