Trying to run the example with MongoDB as the datastore.
from flask import Flask
from flask.ext.mongoengine import MongoEngine
from flask.ext.security import Security
from flask.ext.security.datastore.mongoengine import MongoEngineUserDatastore
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret'
app.config['MONGODB_DB'] = 'auth_test'
app.config['MONGODB_HOST'] = 'ds035997.mongolab.com'
app.config['MONGODB_PORT'] = 35997
db = MongoEngine(app)
Security(app, MongoEngineUserDatastore(db))
@app.before_first_request
def before_first_request():
user_datastore.create_role(name='admin')
user_datastore.create_user(username='asselinpaul', email='[email protected]',
password='paa1946', roles=['admin'])
@app.route("/login")
def login():
return render_template('login.html', form=LoginForm())
@app.route('/profile')
@login_required
def profile():
return render_template('profile.html')
I've install Flask and Flask-Security through virtualenv and can't see what's wrong, any help?
Thanks in advance.
Paul
You'll need to import login_required ofcourse. Like this:
from flask.ext.security import login_required
Thanks, I'll give it a shot
Most helpful comment
You'll need to import login_required ofcourse. Like this:
from flask.ext.security import login_required