No use of permission and role. Beta prototype is almost working.

parent 1e3114b9
......@@ -22,8 +22,6 @@ from flask import render_template, current_app, request, flash, session, \
url_for, redirect, g, send_from_directory, make_response, abort, Markup
from flask.ext.login import LoginManager, login_user, logout_user, \
login_required, current_user, AnonymousUserMixin
from flask.ext.principal import Principal, Identity, AnonymousIdentity, \
identity_changed, identity_loaded, Permission, RoleNeed, UserNeed
import conf
from web.decorators import to_response
......@@ -51,37 +49,12 @@ def redirect_url(default='profile'):
request.referrer or \
# Management of the permissions
principals = Principal(app)
# Create a permission with an admin role's need
admin_permission = Permission(RoleNeed('admin'))
login_manager = LoginManager(app)
login_manager.login_view = 'login'
login_manager.login_message = 'Please log in to access this page.'
login_manager.login_message_category = 'danger'
def on_identity_loaded(sender, identity):
# Set the identity user object
g.user = current_user
identity.user = current_user
# Add the UserNeed to the identity
if hasattr(current_user, 'id'):
# Assuming the User model has a list of roles, update the
# identity with the roles that the user provides
if hasattr(current_user, 'roles'):
for role in current_user.roles:
def authentication_failed(e):
flash('You do not have enough rights.', 'danger')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment