Created
December 5, 2015 21:14
-
-
Save bq1990/ba145bb6c6115c715c18 to your computer and use it in GitHub Desktop.
Subscribe to user_created signal for Flask-Stormpath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from os.path import expanduser | |
from flask import Flask | |
from flask.ext.stormpath import StormpathManager, login_required | |
from flask_stormpath.models import user_created | |
app = Flask(__name__) | |
app.config['SECRET_KEY'] = 'xxx' | |
app.config['STORMPATH_API_KEY_FILE'] = expanduser('stormpath.properties') | |
app.config['STORMPATH_APPLICATION'] = 'test-signal' | |
stormpath_manager = StormpathManager(app) | |
def user_created_callback(sender, user=None): | |
print('user created!!!') | |
user_created.connect(user_created_callback, app) | |
@app.route('/') | |
def home(): | |
return 'home page!' | |
@app.route('/secret') | |
@login_required | |
def secret(): | |
return 'secret page!' | |
if __name__ == '__main__': | |
app.run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment