update
This commit is contained in:
@@ -1,4 +1,3 @@
|
|||||||
from datetime import timedelta
|
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
from typing import Annotated
|
from typing import Annotated
|
||||||
from uuid import uuid4
|
from uuid import uuid4
|
||||||
@@ -27,7 +26,6 @@ def session(
|
|||||||
username: Annotated[str, Body()],
|
username: Annotated[str, Body()],
|
||||||
password: Annotated[str, Body()],
|
password: Annotated[str, Body()],
|
||||||
):
|
):
|
||||||
now_ = now()
|
|
||||||
user_id, password_hash = _get_user(username)
|
user_id, password_hash = _get_user(username)
|
||||||
|
|
||||||
if not pbkdf2_sha256.verify(password, password_hash):
|
if not pbkdf2_sha256.verify(password, password_hash):
|
||||||
@@ -42,7 +40,7 @@ def session(
|
|||||||
http_only=True,
|
http_only=True,
|
||||||
secure=True,
|
secure=True,
|
||||||
same_site=None,
|
same_site=None,
|
||||||
expires=now_ + timedelta(seconds=JWT_EXP_SECONDS),
|
max_age=JWT_EXP_SECONDS,
|
||||||
)
|
)
|
||||||
],
|
],
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,2 +1,3 @@
|
|||||||
export const FOUND = 302
|
export const FOUND = 302
|
||||||
export const BAD_REQUEST = 400
|
export const BAD_REQUEST = 400
|
||||||
|
export const INTERNAL_SERVER = 500
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ export async function loader({ request, context }: Route.LoaderArgs) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (r.status === httpStatus.BAD_REQUEST) {
|
if (r.status === httpStatus.BAD_REQUEST) {
|
||||||
|
console.log(r)
|
||||||
return new Response(null, {
|
return new Response(null, {
|
||||||
status: httpStatus.FOUND,
|
status: httpStatus.FOUND,
|
||||||
headers: {
|
headers: {
|
||||||
@@ -44,6 +45,6 @@ export async function loader({ request, context }: Route.LoaderArgs) {
|
|||||||
headers: r.headers
|
headers: r.headers
|
||||||
})
|
})
|
||||||
} catch {
|
} catch {
|
||||||
return new Response(null, { status: 500 })
|
return new Response(null, { status: httpStatus.INTERNAL_SERVER })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ export async function action({ request, context }: Route.ActionArgs) {
|
|||||||
headers
|
headers
|
||||||
})
|
})
|
||||||
} catch {
|
} catch {
|
||||||
return new Response(null, { status: 500 })
|
return new Response(null, { status: httpStatus.INTERNAL_SERVER })
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,7 +68,6 @@ export default function Index({}: Route.ComponentProps) {
|
|||||||
|
|
||||||
const onSubmit = async (data: Schema) => {
|
const onSubmit = async (data: Schema) => {
|
||||||
await fetcher.submit(data, { method: 'post' })
|
await fetcher.submit(data, { method: 'post' })
|
||||||
console.log(fetcher.data)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user