feat: add GetRandomQuoteAction

This commit is contained in:
cătălin 2025-02-13 09:52:15 +01:00
commit 75df191253
No known key found for this signature in database
13 changed files with 185 additions and 218 deletions

View file

@ -1,6 +1,7 @@
import secrets
from litestar import MediaType, get
from litestar.datastructures.cookie import Cookie
from litestar.response import Redirect, Template
from src.huesoporro.actions.authenticate import AuthenticateAction
@ -10,7 +11,16 @@ from src.huesoporro.settings import Settings
@get(path="/o/code")
async def get_code(code: str, authenticate_action: AuthenticateAction) -> Redirect:
token = await authenticate_action.run(code)
return Redirect("/", cookies={"huesoporroAuth": token})
return Redirect(
"/",
cookies=[
Cookie(
key="huesoporroAuth",
value=token,
expires=604800, # 1 week
)
],
)
@get(