code: def with_user_roles(roles):
      
      def wrapper(f):
          @functools.wraps(f)
          def wrapped(*args, **kwargs):
              if current_user.is_authenticated():
                  if not hasattr(current_user, "role"):
                      raise AttributeError("<'role'> doesn't exist in login 'current_user'")
                  if current_user.role not in roles:
                      return abort(403)
              else:
                  return abort(401)
              return f(*args, **kwargs)
          return wrapped
      return wrapper
docs: with_user_roles(roles)
  
      It allows to check if a user has access to a view by adding the decorator
      with_user_roles([])
  
      Requires flask-login
  
      In your model, you must have a property 'role', which will be invoked to
      be compared to the roles provided.
  
      If current_user doesn't have a role, it will throw a 403
  
      If the current_user is not logged in will throw a 401
  
      * Require Flask-Login
      ---
      Usage
  
      @app.route('/user')
      @login_require
      @with_user_roles(['admin', 'user'])
      def user_page(self):
          return "You've got permission to access this page."