File: //home/arjun/projects/buyercall/buyercall/blueprints/user/__pycache__/decorators.cpython-310.pyc
o
weK � @ sv d dl mZ d dlmZmZ d dlmZ d dlmZ d dl m
Z d dlm
Z
d dlmZ dd d
�Zdd� Zd
d� ZdS )� ��wraps)�flash�redirect)�url_for)�jsonify)�gettext)�current_user)�api_jsonify� /settingsc � � fdd�}|S )z�
Redirect a user to a specified location if they are already signed in.
:param url: URL to be redirected to if invalid
:type url: str
:return: Function
c � t � �� �fdd��}|S )Nc s t jrt��S � | i |��S )N)r �is_authenticatedr ��args�kwargs)�f�url� �F/home/arjun/projects/buyercall/buyercall/blueprints/user/decorators.py�decorated_function s zAanonymous_required.<locals>.decorator.<locals>.decorated_functionr �r r �r �r r � decorator s z%anonymous_required.<locals>.decoratorr )r r r r r �anonymous_required s
r c r )�z
Does a user have permission to view this page?
:param *roles: 1 or more allowed roles
:return: Function
c r
)Nc sP t jrt j�vrttd�d� td�S n
ttd�d� ttd��S � | i |��S )Nz&You do not have permission to do that.�danger�/z
user.login)r r �roler �_r r r �r �rolesr r r * s
�z<role_required.<locals>.decorator.<locals>.decorated_functionr r �r"