Skip to content

Instantly share code, notes, and snippets.

@bq1990
Created December 5, 2015 21:14
Show Gist options
  • Save bq1990/ba145bb6c6115c715c18 to your computer and use it in GitHub Desktop.
Save bq1990/ba145bb6c6115c715c18 to your computer and use it in GitHub Desktop.
Subscribe to user_created signal for Flask-Stormpath
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