B
    /¡éf  ã               @   s8   d dl mZ d dlmZmZmZ d dlmZ dd„ ZdS )é    )Úwraps)ÚredirectÚurl_forÚflash)Úcurrent_userc                 s   ‡ fdd„}|S )z;Decorator to restrict access to routes based on user roles.c                s   t ˆ ƒ‡ ‡fdd„ƒ}|S )Nc                 sF   t jstddƒ ttdƒƒS t jˆkr<tddƒ ttdƒƒS ˆ | |ŽS )Nz-You need to be logged in to access this page.Údangerz
auth.loginz6You do not have the required role to access this page.z
auth.index)r   Úis_authenticatedr   r   r   Úrole)ÚargsÚkwargs)ÚfÚroles© ú?C:\Users\Lenovo\Desktop\Projects\times_travel\app\decorators.pyÚdecorated_function   s    


z=roles_required.<locals>.decorator.<locals>.decorated_function)r   )r   r   )r   )r   r   Ú	decorator   s    	z!roles_required.<locals>.decoratorr   )r   r   r   )r   r   Úroles_required   s    r   N)	Ú	functoolsr   Úflaskr   r   r   Úflask_loginr   r   r   r   r   r   Ú<module>   s   