How to override a method of flask-security (register_user)?
See original GitHub issueHello,
I’m trying without success to override a behavior of Flask-Security: sending confirmation emails. I would like them to be sent to a default e-mail address, whatever the candidate user submitted. So that the administrator can review and filter who’s registering.
It seems the confirmation email is sent by flask.ext.security.registerable.register_user()
def new_register_user(**kwargs):
# Define a method with new behavior
...
import sys
# Override registerable module method
import flask.ext.security.registerable
sys.modules['flask.ext.security.registerable'].register_user = new_register_user
sys.modules['flask.ext.security'].registerable.register_user = new_register_user
# When printing sys.modules, it seems that registerable module
# appears also there:
import flask_security
sys.modules['flask_security.registerable'].register_user = new_register_user
sys.modules['flask_security'].registerable.register_user = new_register_user
Unfortunately, it does not work. The original method is still used. Do you have any hints?
Issue Analytics
- State:
- Created 9 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to override login of flask-security?
You can override the login form when you are setting up Flask-Security: user_datastore = SQLAlchemyUserDatastore(db, User, Role) security ...
Read more >Customizing — Flask-Security 5.0.2 documentation
Forms¶. All forms can be overridden. For each form used, you can specify a replacement class. This allows you to add extra fields...
Read more >flask-peewee Documentation
4.2.1 Overriding Admin Templates. Use the ModelAdmin.get_template_overrides() method to override templates for an individual Model:.
Read more >Customizing Views — Flask-Security 3.0.0 documentation
Forms¶. All forms can be overridden. For each form used, you can specify a replacement class. This allows you to add extra fields...
Read more >Intro to Flask-Security - YouTube
Flask-Security is a library you can use to handle things like authentication and authorization in your app. In this video I show you...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
The feature mentioned by @Trii is documented (a little) here: https://flask-security.readthedocs.io/en/latest/customizing.html#emails.
Thank you for posting the override functionality! Was just what I needed! Would be great to have this in the docs