RBAC, Permissions, and Export/Import

This commit is contained in:
Koncept Kit
2025-12-16 20:03:50 +07:00
parent b268c3fff8
commit ed5526e27b
27 changed files with 10284 additions and 73 deletions

View File

@@ -376,3 +376,77 @@ async def send_admin_password_reset_email(
"""
return await send_email(to_email, subject, html_content)
async def send_invitation_email(
to_email: str,
inviter_name: str,
invitation_url: str,
role: str
):
"""Send invitation email to new user"""
subject = f"You've Been Invited to Join LOAF - {role.capitalize()} Access"
role_descriptions = {
"member": "full member access to our community",
"admin": "administrative access to manage the platform",
"superadmin": "full administrative access with system-wide permissions"
}
role_description = role_descriptions.get(role.lower(), "access to our platform")
html_content = f"""
<!DOCTYPE html>
<html>
<head>
<style>
body {{ font-family: 'Nunito Sans', Arial, sans-serif; line-height: 1.6; color: #422268; }}
.container {{ max-width: 600px; margin: 0 auto; padding: 20px; }}
.header {{ background: linear-gradient(135deg, #644c9f 0%, #48286e 100%); padding: 30px; text-align: center; border-radius: 10px 10px 0 0; }}
.header h1 {{ color: white; margin: 0; font-family: 'Inter', sans-serif; }}
.content {{ background: #FFFFFF; padding: 30px; border-radius: 0 0 10px 10px; }}
.button {{ display: inline-block; background: #ff9e77; color: #FFFFFF; padding: 15px 40px; text-decoration: none; border-radius: 50px; font-weight: 600; margin: 20px 0; }}
.button:hover {{ background: #e88d66; }}
.info-box {{ background: #f1eef9; padding: 20px; border-radius: 8px; margin: 20px 0; border: 2px solid #ddd8eb; }}
.note {{ background: #FFEBEE; border-left: 4px solid #ff9e77; padding: 15px; margin: 20px 0; }}
</style>
</head>
<body>
<div class="container">
<div class="header">
<h1>🎉 You're Invited!</h1>
</div>
<div class="content">
<p><strong>{inviter_name}</strong> has invited you to join the LOAF community with <strong>{role_description}</strong>.</p>
<div class="info-box">
<p style="margin: 0;"><strong>Your Role:</strong> {role.capitalize()}</p>
<p style="margin: 10px 0 0 0;"><strong>Invited By:</strong> {inviter_name}</p>
</div>
<p>Click the button below to accept your invitation and create your account:</p>
<p style="text-align: center;">
<a href="{invitation_url}" class="button">Accept Invitation</a>
</p>
<div class="note">
<p style="margin: 0; font-size: 14px;"><strong>⏰ This invitation expires in 7 days.</strong></p>
<p style="margin: 5px 0 0 0; font-size: 14px;">If you didn't expect this invitation, you can safely ignore this email.</p>
</div>
<p style="margin-top: 20px; color: #664fa3; font-size: 14px;">
Or copy and paste this link into your browser:<br>
<span style="word-break: break-all;">{invitation_url}</span>
</p>
<p style="margin-top: 30px; padding-top: 20px; border-top: 1px solid #ddd8eb; color: #664fa3; font-size: 14px;">
Questions? Contact us at support@loaf.org
</p>
</div>
</div>
</body>
</html>
"""
return await send_email(to_email, subject, html_content)