def has_sudo_privileges(request):
    """
    Check if a request is allowed to perform sudo actions
    """
    if getattr(request, '_sudo', None) is None:
        try:
            request._sudo = (
                request.user.is_authenticated() and
                constant_time_compare(
                    request.get_signed_cookie(COOKIE_NAME, salt=COOKIE_SALT, max_age=COOKIE_AGE),
                    request.session[COOKIE_NAME]
                )
            )
        except (KeyError, BadSignature):
            request._sudo = False
    return request._sudo
def has_sudo_privileges ( request ) : if getattr ( request , '_sudo' , None ) is None : try : request . _sudo = ( request . user . is_authenticated ( ) and constant_time_compare ( request . get_signed_cookie ( COOKIE_NAME , salt = COOKIE_SALT , max_age = COOKIE_AGE ) , request . session [ COOKIE_NAME ] ) ) except ( KeyError , BadSignature ) : request . _sudo = False return request . _sudo
Check if a request is allowed to perform sudo actions