Ejemplo n.º 1
0
    def decorated_view(*args, **kwargs):
        # User must be authenticated
        if not is_authenticated():
            # Redirect to unauthenticated page
            return abort(401)

        # Call the actual view
        return func(*args, **kwargs)
Ejemplo n.º 2
0
    def get_account_view_endpoint(suffix=None):
        """Returns 'ROLE_account.X' based on current_user
        """
        if not is_authenticated():
            raise Exception("Attempt to call get_account_view_endpoint without authentication")

        assert len(current_user.roles) == 1, 'User has more than 1 role!'
        if suffix:
            return '%s_account.%s' % (current_user.roles[0].name, suffix)
        return '%s_account' % current_user.roles[0].name
Ejemplo n.º 3
0
 def inaccessible_callback(self, name, **kwargs):
     if not is_authenticated():
         return current_app.user_manager.unauthenticated_view_function()
     if not current_user.has_role(*self.get_accessible_roles()):
         return current_app.user_manager.unauthorized_view_function()
Ejemplo n.º 4
0
 def is_accessible(self):
     if not is_authenticated():
         return False
     if not current_user.has_role(*self.get_accessible_roles()):
         return False
     return True
Ejemplo n.º 5
0
 def is_accessible(self):
     if not is_authenticated():
         return False
     if current_user.username in self.usernames:
         return True
     return False
Ejemplo n.º 6
0
 def default_page():
     if is_authenticated():
         return redirect(url_for('user.member_page'))
     return redirect(url_for('user.home_page'))