add status
This commit is contained in:
2
id.saladeaula.digital/client/app/lib/http-status.ts
Normal file
2
id.saladeaula.digital/client/app/lib/http-status.ts
Normal file
@@ -0,0 +1,2 @@
|
||||
export const FOUND = 302
|
||||
export const BAD_REQUEST = 400
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user