-
I've created new custom templates for login/registration as per the documentation and they're mostly working as expected. I included blocks for Flask message flashing. For various reasons, I did not leverage Flask-WTF for form rendering and would prefer to keep it that way. It seems a side effect of this choice is that the front end will not render messages like "email is already associated with an account" if a duplicate email is used for registration, which you would see on the default security What do I need to do to pass all the messages? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
First - the way I think about flashing versus validation errors is that flashing is useful when the operation ends up redirecting the user to a different page/form - and the 'flash' gives information about why (e.g. successful login). I am a bit confused - you say you added new templates - but sounds like you are still using the same default forms. All Flask-Security forms are based on Flask-WTF. You can override those forms - but then you are repeating a lot of work. When you say 'did not leverage Flask-WTF for form rendering' I am not sure what you mean - the template rendering is done (by default) Flask's render_template() method. So you should be seeing all the errors in your response form (unless you did override the forms as well). Flashing is outside of any form and is implemented using Flask::flash and Flash::get_flashed_messages (which your templates can call) If you really don't want to use Flask-WTF - then you have to define all your own forms including validation etc - and be sure to implement CSRF protection. Now - possibly you are asking - can I flash all errors instead of returning some as validation errors on a specific field... Hmm - I think that could be done by implementing a context_processor and in that look for errors and turn them into flashes.... |
Beta Was this translation helpful? Give feedback.
First - the way I think about flashing versus validation errors is that flashing is useful when the operation ends up redirecting the user to a different page/form - and the 'flash' gives information about why (e.g. successful login).
If there are errors that the user should fix - such as validation errors - those are better returned as part of the form so the user can fix and re-submit.
I am a bit confused - you say you added new templates - but sounds like you are still using the same default forms. All Flask-Security forms are based on Flask-WTF. You can override those forms - but then you are repeating a lot of work.
When you say 'did not leverage Flask-WTF for form rendering' I am no…