Use decode method to decode the byte string instead of casting it to string and replacing the byte string syntax in the string.

This commit is contained in:
nswain
2020-09-09 09:04:44 -06:00
parent d48e464c16
commit c34efd6ba9

View File

@@ -14,9 +14,7 @@ def sendEmail(request,username,secret):
kwargs = {key: username} kwargs = {key: username}
user = User.objects.get(**kwargs) user = User.objects.get(**kwargs)
res=render(request,"mfa_email_token_template.html",{"request":request,"user":user,'otp':secret}) res=render(request,"mfa_email_token_template.html",{"request":request,"user":user,'otp':secret})
body = str(res.content).replace("b'", "") return send([user.email],"OTP", res.content.decode())
body = body[:-1] if body.endswith("'") else body
return send([user.email],"OTP", body)
@never_cache @never_cache
def start(request): def start(request):