
from functools import wraps

from flask import abort, g


def permission_required(permission):
    """Ensure the current user has the given permission."""
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if permission not in g.current_user.permissions:
                abort(403)
            return func(*args, **kwargs)
        return wrapper
    return decorator


def role_required(role):
    """Ensure the current user has the given role."""
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if role not in g.current_user.roles:
                abort(403)
            return func(*args, **kwargs)
        return wrapper
    return decorator


from functools import wraps

from flask import abort, g


def permission_required(permission):
    """Ensure the current user has the given permission."""
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if permission not in g.current_user.permissions:
                abort(403)
            return func(*args, **kwargs)
        return wrapper
    return decorator

Remove `role_required` decorator as only specific permissions, not roles, should be explicitly required
Remove `role_required` decorator as only specific permissions, not roles, should be explicitly required

  
  from functools import wraps
  
  from flask import abort, g
  
  
  def permission_required(permission):
      """Ensure the current user has the given permission."""
      def decorator(func):
          @wraps(func)
          def wrapper(*args, **kwargs):
              if permission not in g.current_user.permissions:
                  abort(403)
              return func(*args, **kwargs)
          return wrapper
      return decorator
  
- 
- def role_required(role):
-     """Ensure the current user has the given role."""
-     def decorator(func):
-         @wraps(func)
-         def wrapper(*args, **kwargs):
-             if role not in g.current_user.roles:
-                 abort(403)
-             return func(*args, **kwargs)
-         return wrapper
-     return decorator
- 
Remove `role_required` decorator as only specific permissions, not roles, should be explicitly required
## Code Before:

from functools import wraps

from flask import abort, g


def permission_required(permission):
    """Ensure the current user has the given permission."""
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if permission not in g.current_user.permissions:
                abort(403)
            return func(*args, **kwargs)
        return wrapper
    return decorator


def role_required(role):
    """Ensure the current user has the given role."""
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if role not in g.current_user.roles:
                abort(403)
            return func(*args, **kwargs)
        return wrapper
    return decorator

## Instruction:
Remove `role_required` decorator as only specific permissions, not roles, should be explicitly required
## Code After:

from functools import wraps

from flask import abort, g


def permission_required(permission):
    """Ensure the current user has the given permission."""
    def decorator(func):
        @wraps(func)
        def wrapper(*args, **kwargs):
            if permission not in g.current_user.permissions:
                abort(403)
            return func(*args, **kwargs)
        return wrapper
    return decorator
