lol
This commit is contained in:
+648
-55
@@ -1082,57 +1082,333 @@ def api_update_email(
|
||||
@app.get(
|
||||
"/verify-email",
|
||||
response_class=HTMLResponse,
|
||||
summary="Verify email address",
|
||||
)
|
||||
def api_verify_email(token: str = Query(...)):
|
||||
def api_verify_email(
|
||||
token: str = Query(...),
|
||||
):
|
||||
result = verify_email(token)
|
||||
|
||||
if result["status"] == "failed":
|
||||
if result["reason"] == "token_expired":
|
||||
return """
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Verification expired</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Verification expired</h1>
|
||||
<p>This verification link has expired.</p>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
return """
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Verification failed</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Verification failed</h1>
|
||||
<p>This verification link is invalid.</p>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
|
||||
return """
|
||||
return HTMLResponse(
|
||||
content="""
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Email verified</title>
|
||||
|
||||
<title>Verification expired</title>
|
||||
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
|
||||
background: #0b0d10;
|
||||
color: #e8eaed;
|
||||
|
||||
font-family:
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
max-width: 460px;
|
||||
padding: 40px;
|
||||
|
||||
background: #15181d;
|
||||
border: 1px solid #2a2f36;
|
||||
border-radius: 14px;
|
||||
|
||||
text-align: center;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
margin: 0 auto 24px;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
border-radius: 50%;
|
||||
background: #2b2115;
|
||||
color: #f0a83b;
|
||||
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
color: #9da4ae;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 28px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #272c33;
|
||||
|
||||
color: #6f7782;
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="box">
|
||||
<h1>Email verified</h1>
|
||||
<p>Your email address has been successfully verified.</p>
|
||||
<p>You may now close this tab.</p>
|
||||
<main class="card">
|
||||
<div class="icon">!</div>
|
||||
|
||||
<h1>Verification expired</h1>
|
||||
|
||||
<p>
|
||||
This email verification link has expired.
|
||||
Please request a new verification email.
|
||||
</p>
|
||||
|
||||
<div class="footer">
|
||||
Calendar API
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
""",
|
||||
status_code=410,
|
||||
)
|
||||
|
||||
return HTMLResponse(
|
||||
content="""
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Verification failed</title>
|
||||
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
|
||||
background: #0b0d10;
|
||||
color: #e8eaed;
|
||||
|
||||
font-family:
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
max-width: 460px;
|
||||
padding: 40px;
|
||||
|
||||
background: #15181d;
|
||||
border: 1px solid #2a2f36;
|
||||
border-radius: 14px;
|
||||
|
||||
text-align: center;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
margin: 0 auto 24px;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
border-radius: 50%;
|
||||
background: #2a1719;
|
||||
color: #ef6461;
|
||||
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
color: #9da4ae;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 28px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #272c33;
|
||||
|
||||
color: #6f7782;
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="card">
|
||||
<div class="icon">×</div>
|
||||
|
||||
<h1>Verification failed</h1>
|
||||
|
||||
<p>
|
||||
This verification link is invalid or has already been used.
|
||||
</p>
|
||||
|
||||
<div class="footer">
|
||||
Calendar API
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
""",
|
||||
status_code=400,
|
||||
)
|
||||
|
||||
return HTMLResponse(
|
||||
content="""
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Email verified</title>
|
||||
|
||||
<style>
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
|
||||
background: #0b0d10;
|
||||
color: #e8eaed;
|
||||
|
||||
font-family:
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
sans-serif;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
max-width: 460px;
|
||||
padding: 40px;
|
||||
|
||||
background: #15181d;
|
||||
border: 1px solid #2a2f36;
|
||||
border-radius: 14px;
|
||||
|
||||
text-align: center;
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
margin: 0 auto 24px;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
border-radius: 50%;
|
||||
background: #14271d;
|
||||
color: #4ade80;
|
||||
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0 0 12px;
|
||||
font-size: 26px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 8px 0 0;
|
||||
color: #9da4ae;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.footer {
|
||||
margin-top: 28px;
|
||||
padding-top: 20px;
|
||||
border-top: 1px solid #272c33;
|
||||
|
||||
color: #6f7782;
|
||||
font-size: 13px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="card">
|
||||
<div class="icon">✓</div>
|
||||
|
||||
<h1>Email verified</h1>
|
||||
|
||||
<p>
|
||||
Your email address has been successfully verified.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You may now close this tab.
|
||||
</p>
|
||||
|
||||
<div class="footer">
|
||||
Calendar API
|
||||
</div>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
""",
|
||||
)
|
||||
|
||||
@app.post(
|
||||
"/forgot-password",
|
||||
@@ -1147,47 +1423,194 @@ def api_forgot_password(
|
||||
@app.get(
|
||||
"/update-password_page",
|
||||
response_class=HTMLResponse,
|
||||
summary="Password reset page",
|
||||
)
|
||||
def update_password_page(token: str = Query(...)):
|
||||
return f"""
|
||||
def update_password_page(
|
||||
token: str = Query(...),
|
||||
):
|
||||
return HTMLResponse(
|
||||
content=f"""
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Reset password</title>
|
||||
|
||||
<style>
|
||||
* {{
|
||||
box-sizing: border-box;
|
||||
}}
|
||||
|
||||
body {{
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
padding: 24px;
|
||||
|
||||
background: #0b0d10;
|
||||
color: #e8eaed;
|
||||
|
||||
font-family:
|
||||
system-ui,
|
||||
-apple-system,
|
||||
BlinkMacSystemFont,
|
||||
"Segoe UI",
|
||||
sans-serif;
|
||||
}}
|
||||
|
||||
.card {{
|
||||
width: 100%;
|
||||
max-width: 460px;
|
||||
padding: 40px;
|
||||
|
||||
background: #15181d;
|
||||
border: 1px solid #2a2f36;
|
||||
border-radius: 14px;
|
||||
|
||||
box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
|
||||
}}
|
||||
|
||||
h1 {{
|
||||
margin: 0 0 10px;
|
||||
font-size: 28px;
|
||||
}}
|
||||
|
||||
.description {{
|
||||
margin: 0 0 30px;
|
||||
color: #9da4ae;
|
||||
line-height: 1.6;
|
||||
}}
|
||||
|
||||
label {{
|
||||
display: block;
|
||||
margin-bottom: 8px;
|
||||
|
||||
color: #c7ccd3;
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
}}
|
||||
|
||||
input {{
|
||||
width: 100%;
|
||||
padding: 13px 14px;
|
||||
|
||||
border: 1px solid #343a43;
|
||||
border-radius: 8px;
|
||||
|
||||
background: #0f1216;
|
||||
color: #e8eaed;
|
||||
|
||||
font-size: 15px;
|
||||
|
||||
outline: none;
|
||||
}}
|
||||
|
||||
input:focus {{
|
||||
border-color: #6b7280;
|
||||
}}
|
||||
|
||||
button {{
|
||||
width: 100%;
|
||||
margin-top: 22px;
|
||||
padding: 13px 16px;
|
||||
|
||||
border: 0;
|
||||
border-radius: 8px;
|
||||
|
||||
background: #e8eaed;
|
||||
color: #111318;
|
||||
|
||||
font-size: 15px;
|
||||
font-weight: 600;
|
||||
|
||||
cursor: pointer;
|
||||
}}
|
||||
|
||||
button:hover {{
|
||||
background: #ffffff;
|
||||
}}
|
||||
|
||||
.requirements {{
|
||||
margin-top: 10px;
|
||||
|
||||
color: #6f7782;
|
||||
font-size: 13px;
|
||||
}}
|
||||
|
||||
.footer {{
|
||||
margin-top: 28px;
|
||||
padding-top: 20px;
|
||||
|
||||
border-top: 1px solid #272c33;
|
||||
|
||||
color: #6f7782;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
}}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="card">
|
||||
|
||||
<h1>Reset password</h1>
|
||||
|
||||
<form method="post" action="/api/update-password">
|
||||
<p class="description">
|
||||
Enter a new password for your account.
|
||||
</p>
|
||||
|
||||
<form
|
||||
method="post"
|
||||
action="/update-password"
|
||||
>
|
||||
<input
|
||||
type="hidden"
|
||||
name="token"
|
||||
value="{token}"
|
||||
>
|
||||
|
||||
<label>
|
||||
New password:
|
||||
<label for="new_password">
|
||||
New password
|
||||
</label>
|
||||
|
||||
<input
|
||||
id="new_password"
|
||||
type="password"
|
||||
name="new_password"
|
||||
minlength="8"
|
||||
autocomplete="new-password"
|
||||
required
|
||||
>
|
||||
</label>
|
||||
|
||||
<div class="requirements">
|
||||
Minimum 8 characters.
|
||||
</div>
|
||||
|
||||
<button type="submit">
|
||||
Reset password
|
||||
Update password
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div class="footer">
|
||||
Calendar API
|
||||
</div>
|
||||
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
""",
|
||||
)
|
||||
|
||||
@app.post(
|
||||
"/update-password",
|
||||
response_class=HTMLResponse,
|
||||
summary="Reset password",
|
||||
)
|
||||
def update_password(
|
||||
token: str = Form(...),
|
||||
@@ -1199,49 +1622,219 @@ def update_password(
|
||||
)
|
||||
|
||||
if result["status"] == "failed":
|
||||
|
||||
if result["reason"] == "token_expired":
|
||||
return """
|
||||
return HTMLResponse(
|
||||
content="""
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Reset expired</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Reset link expired</title>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
|
||||
background: #0b0d10;
|
||||
color: #e8eaed;
|
||||
|
||||
font-family: system-ui, sans-serif;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
max-width: 460px;
|
||||
padding: 40px;
|
||||
|
||||
background: #15181d;
|
||||
border: 1px solid #2a2f36;
|
||||
border-radius: 14px;
|
||||
|
||||
text-align: center;
|
||||
box-shadow: 0 20px 60px rgba(0,0,0,.45);
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
p {
|
||||
color: #9da4ae;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="card">
|
||||
<h1>Reset link expired</h1>
|
||||
<p>This password reset link has expired.</p>
|
||||
|
||||
<p>
|
||||
This password reset link has expired.
|
||||
Please request a new password reset.
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
""",
|
||||
status_code=410,
|
||||
)
|
||||
|
||||
return """
|
||||
return HTMLResponse(
|
||||
content="""
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Reset failed</title>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
|
||||
background: #0b0d10;
|
||||
color: #e8eaed;
|
||||
|
||||
font-family: system-ui, sans-serif;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
max-width: 460px;
|
||||
padding: 40px;
|
||||
|
||||
background: #15181d;
|
||||
border: 1px solid #2a2f36;
|
||||
border-radius: 14px;
|
||||
|
||||
text-align: center;
|
||||
box-shadow: 0 20px 60px rgba(0,0,0,.45);
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
p {
|
||||
color: #9da4ae;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="card">
|
||||
<h1>Reset failed</h1>
|
||||
<p>This password reset link is invalid.</p>
|
||||
|
||||
<p>
|
||||
This password reset link is invalid or has already been used.
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
""",
|
||||
status_code=400,
|
||||
)
|
||||
|
||||
return """
|
||||
return HTMLResponse(
|
||||
content="""
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<title>Password updated</title>
|
||||
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
min-height: 100vh;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: 24px;
|
||||
|
||||
background: #0b0d10;
|
||||
color: #e8eaed;
|
||||
|
||||
font-family: system-ui, sans-serif;
|
||||
}
|
||||
|
||||
.card {
|
||||
width: 100%;
|
||||
max-width: 460px;
|
||||
padding: 40px;
|
||||
|
||||
background: #15181d;
|
||||
border: 1px solid #2a2f36;
|
||||
border-radius: 14px;
|
||||
|
||||
text-align: center;
|
||||
box-shadow: 0 20px 60px rgba(0,0,0,.45);
|
||||
}
|
||||
|
||||
.icon {
|
||||
width: 64px;
|
||||
height: 64px;
|
||||
margin: 0 auto 24px;
|
||||
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
|
||||
border-radius: 50%;
|
||||
background: #14271d;
|
||||
color: #4ade80;
|
||||
|
||||
font-size: 30px;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin: 0 0 12px;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
color: #9da4ae;
|
||||
line-height: 1.6;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<main class="card">
|
||||
<div class="icon">✓</div>
|
||||
|
||||
<h1>Password updated</h1>
|
||||
<p>Your password has been successfully changed.</p>
|
||||
<p>You may now close this tab.</p>
|
||||
|
||||
<p>
|
||||
Your password has been successfully changed.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
You may now close this tab.
|
||||
</p>
|
||||
</main>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
""",
|
||||
)
|
||||
|
||||
# easter egg
|
||||
|
||||
|
||||
Reference in New Issue
Block a user