question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to override a method of flask-security (register_user)?

See original GitHub issue

Hello,

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:closed
  • Created 9 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
andreibancioiucommented, Aug 22, 2017

The feature mentioned by @Trii is documented (a little) here: https://flask-security.readthedocs.io/en/latest/customizing.html#emails.

2reactions
herman5commented, May 21, 2016

Thank you for posting the override functionality! Was just what I needed! Would be great to have this in the docs

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found