-
Notifications
You must be signed in to change notification settings - Fork 9
feat: cool dev ui #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
d473476
33add80
0af6214
0353232
1229f2b
2383d67
d1a7b9c
61c85c7
bb191ba
079bf7d
47aa485
5372272
6593ed2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
from podium.config import settings as settings | ||
from podium.config import settings as settings, environment as environment |
Original file line number | Diff line number | Diff line change | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
@@ -1,10 +1,9 @@ | ||||||||||
from datetime import datetime, timedelta, timezone | ||||||||||
|
||||||||||
# import smtplib | ||||||||||
# from email.mime.text import MIMEText | ||||||||||
from typing import Annotated | ||||||||||
|
||||||||||
from podium import db, settings | ||||||||||
from podium import db, settings, environment | ||||||||||
|
||||||||||
from fastapi import APIRouter, HTTPException, Query, Depends | ||||||||||
from fastapi.security import HTTPBearer, HTTPAuthorizationCredentials | ||||||||||
|
@@ -23,7 +22,7 @@ | |||||||||
ALGORITHM = str(settings.jwt_algorithm) | ||||||||||
ACCESS_TOKEN_EXPIRE_MINUTES: int = settings.jwt_expire_minutes # type: ignore | ||||||||||
MAGIC_LINK_EXPIRE_MINUTES = 15 | ||||||||||
|
||||||||||
magic_urls = [] | ||||||||||
|
||||||||||
DEBUG_EMAIL = "[email protected]" | ||||||||||
|
||||||||||
|
@@ -48,6 +47,9 @@ def create_access_token( | |||||||||
encoded_jwt = jwt.encode(to_encode, SECRET_KEY, algorithm=ALGORITHM) | ||||||||||
return encoded_jwt | ||||||||||
|
||||||||||
def get_mail(): | ||||||||||
""" kinda like /letter_box but in python or smt.""" | ||||||||||
return magic_urls | ||||||||||
|
||||||||||
Comment on lines
49
to
53
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||
async def send_magic_link(email: str, redirect: str = ""): | ||||||||||
token_data = {"sub": email} | ||||||||||
|
@@ -58,7 +60,8 @@ async def send_magic_link(email: str, redirect: str = ""): | |||||||||
magic_link = f"{settings.production_url}/login?token={token}" | ||||||||||
if redirect: | ||||||||||
magic_link += f"&redirect={redirect}" | ||||||||||
|
||||||||||
if environment == "development": | ||||||||||
magic_urls.append(MagicLink(email=email, magic_link=magic_link)) | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. MagicLink isn't defined |
||||||||||
if settings.sendgrid_api_key: | ||||||||||
message = Mail( | ||||||||||
from_email=settings.sendgrid_from_email, | ||||||||||
|
@@ -81,6 +84,13 @@ async def send_magic_link(email: str, redirect: str = ""): | |||||||||
) | ||||||||||
|
||||||||||
|
||||||||||
@router.get("/letter_box") | ||||||||||
async def letter_box(): | ||||||||||
""" | ||||||||||
This is a temporary endpoint to get the magic links that have been sent. | ||||||||||
""" | ||||||||||
return get_mail() | ||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if it's possible, but an even better approach would be to wrap the entire function in a conditional so it's not even defined in prod
Suggested change
|
||||||||||
|
||||||||||
@router.post("/request-login") | ||||||||||
# https://fastapi.tiangolo.com/tutorial/query-param-models/ | ||||||||||
async def request_login(user: UserLoginPayload, redirect: Annotated[str, Query()]): | ||||||||||
|
@@ -297,4 +307,4 @@ def magic_link_email_content(magic_link: str) -> dict: | |||||||||
- Hack Club` | ||||||||||
""" | ||||||||||
|
||||||||||
return {"html": html, "text": text} | ||||||||||
return {"html": html, "text": text} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PUBLIC_API_URL=http://localhost:8000 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<script> | ||
// get text from props | ||
export let text = "Click me"; | ||
</script> | ||
|
||
<button class="btn border-2 border-dashed border-orange-500 bg-orange-500/10"> | ||
{text} | ||
</button> |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,6 +23,7 @@ | |
// Clear the form | ||
eventName = ""; | ||
eventDescription = ""; | ||
await goto('/events'); | ||
} | ||
</script> | ||
|
||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should be using the generated SDK, not |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<script lang="ts"> | ||
import { PUBLIC_API_URL } from "$env/static/public"; | ||
let data = $state([]); | ||
const reload = async () => { | ||
const res = await fetch(`${PUBLIC_API_URL}letter_box`, { | ||
method: "GET", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
if (res.ok) { | ||
const json = await res.json(); | ||
data = json; | ||
console.log(data); | ||
} else { | ||
handleError(res); | ||
} | ||
}; | ||
|
||
const handleError = (res: Response) => { | ||
console.error(`Error: ${res.status} - ${res.statusText}`); | ||
alert("Failed to load data. Please try again later."); | ||
}; | ||
reload(); | ||
</script> | ||
|
||
<div class="hero"> | ||
<div class=" hero-content text-left"> | ||
<div class="max-w-md"> | ||
<h1 class="text-4xl font-bold">Letter box</h1> | ||
<button class="btn btn-primary" onclick={() => reload()}>Reload</button> | ||
<br /> | ||
{#if data && data.length === 0} | ||
<p class="text-base-content/70">No letters found.</p> | ||
{:else} | ||
<ul class="list-disc pl-5"> | ||
{#each data as letter} | ||
<li class="mb-2"> | ||
<strong>{letter[0]}:</strong> | ||
{#let url = new URL(letter[1])} | ||
<a href={url.pathname + url.search}>{letter[1]}</a> | ||
</li> | ||
{/each} | ||
</ul> | ||
{/if} | ||
</div> | ||
</div> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This messes with Coolify