add status

This commit is contained in:
2025-08-17 21:23:02 -03:00
parent 39d9ff99fd
commit 401a81afa0
4 changed files with 11 additions and 4 deletions

View File

@@ -0,0 +1,2 @@
export const FOUND = 302
export const BAD_REQUEST = 400

View File

@@ -1,5 +1,6 @@
import { parse } from 'cookie'
import * as httpStatus from '@/lib/http-status'
import type { Route } from './+types/authorize'
export async function loader({ request, context }: Route.LoaderArgs) {
@@ -12,7 +13,7 @@ export async function loader({ request, context }: Route.LoaderArgs) {
if (!cookies.session_id) {
return new Response(null, {
status: 302,
status: httpStatus.FOUND,
headers: {
Location: redirect.toString()
}
@@ -29,9 +30,9 @@ export async function loader({ request, context }: Route.LoaderArgs) {
redirect: 'manual'
})
if (r.status === 400) {
if (r.status === httpStatus.BAD_REQUEST) {
return new Response(null, {
status: 302,
status: httpStatus.FOUND,
headers: {
Location: redirect.toString()
}

View File

@@ -11,6 +11,7 @@ import { Button } from '@/components/ui/button'
import { Checkbox } from '@/components/ui/checkbox'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import * as httpStatus from '@/lib/http-status'
import { useState } from 'react'
import logo from './logo.svg'
@@ -49,7 +50,7 @@ export async function action({ request, context }: Route.ActionArgs) {
headers.set('Location', url.toString())
return new Response(await r.text(), {
status: 302,
status: httpStatus.FOUND,
headers
})
} catch {