Part 5: Password Reset
Howdy! In the previous Part of the series, we learned how to handle errors in Flask and send a meaningful error m...
For further actions, you may consider blocking this person and/or reporting abuse
The code in your github doesnt work when ran. Just returns server 500s after request is made in Postman.
I just tried running the code from GitHub and everything went well. Can you please provide me more details like, in which endpoint you got
500
. And also the error message in the terminal.Also, did you remember to run python smtp server with
python -m smtpd -n -c DebuggingServer localhost:1025
?I run the smtp server but I still get the "ConnectionRefusedError"
I want to ask: do I have to run it in my virtual environment? or in my normal mac terminal?
It doesn't have to be in your virtual environment. Just remember not to close the terminal running it.
I had the same problem.
My mistake was that I defined the email settings in .env file, and i forgot to import that settings to my app file.
And I still got that error, until I declared my :
mail = Mail(app)
after all that imported settings.
Another correction on this for newer releases of various packages.
In reset_password.py, you have the line:
user_id = decode_token(reset_token)["identity"]
The version of flask-jwt-extended that I have (4.0.2) that must instead read:
user_id = decode_token(reset_token)["sub"]
Again, thanks so much for this guide, i'm learning so much!
This tutorial is excellent! One thing to note, I had to add
MAIL_SUPPRESS_SEND = False
to get the HTML to appear on my localhost:1025 server.I didn't follow this tutorial exactly since my app is already set up slightly differently, but thought this could help anyone else who isn't seeing output on their mail server.
I have a few questions here since I have followed along with all your codes. I just wondering if the user reset their password with their registered email, let's say Gmail, does the user will receive it? Or should I set the Gmail's SMTP from the .env?
Yes you need to set Gmail SMTP configuration. This is only for local development purposes.
The .env file has an error on this page. 'MAIL_SERVER: "localhost"' <<< THe colon needs to be '='.
Fixed it! Thank you π
Hello, thank you for this great article. But when I've tested this uri: /api/auth/forgot with unknown email got error 500 InternalServerError.
So I've updated exception handling unknown e-mail address to:
Is the update in file reset_password.py correct? Seems to be, because now I'm getting error 400 instead of 500
But still wondering about casdade of errors before this one is rised. Is there better way to handle it?
Nice & Useful
Thank you π
Nice !great and very useful
Thank you so much π
Have a good day βΊοΈ
Awesome article!! I have one question If I have to read a value from .env file in windows platform, how to do that?
echo %MAIL_PORT%
echo $MAIL_PORT