♻️ email-function

This commit is contained in:
Mawoka
2022-03-12 17:52:45 +01:00
parent cc29719f7d
commit a089dbf6eb
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -29,7 +29,7 @@ def _sendMail(template: str, to: str, subject: str):
server.sendmail(settings.mail_address, to, msg.as_string())
async def send_mail(email: str):
async def send_register_email(email: str):
user = await User.objects.get_or_none(email=email, verified=False)
if user is None:
raise ValueError('User not found')
+2 -2
View File
@@ -9,7 +9,7 @@ from fastapi.security import OAuth2PasswordRequestForm
from classquiz.auth import *
from classquiz.config import redis
from classquiz.db.models import *
from classquiz.emails import send_mail
from classquiz.emails import send_register_email
router = APIRouter()
@@ -35,7 +35,7 @@ async def create_user(user: route_user, background_task: BackgroundTasks) -> Use
if len(user.username) == 32:
return JSONResponse({"details": "Username mustn't be 32 characters long"}, 400)
await user.save()
background_task.add_task(send_mail, email=user.email)
background_task.add_task(send_register_email, email=user.email)
return user