예제 #1
0
			a = 0
			if user:
				response = self.execute_view(
					fn, request, graph=graph, *args, **kwargs)
			else:
				response = HttpResponse("Voce nao tem permissao para acessar o sistema<br>Para ter acesso repasse esse email para o administrador: " + email)
		except open_facebook_exceptions.OpenFacebookException as e:
			permission_granted = has_permissions(graph, self.scope_list)
			if permission_granted:
				# an error if we already have permissions
				# shouldn't have been caught
				# raise to prevent bugs with error mapping to cause issues
				a = 0
				if a == 0:
					response = self.authentication_failed(
					fn, request, *args, **kwargs)
				else:
					raise
			elif request.REQUEST.get('attempt') == '1':
				# Doing a redirect could end up causing infinite redirects
				# If Facebook is somehow not giving permissions
				# Time to show an error page
				response = self.authentication_failed(
					fn, request, *args, **kwargs)
			else:
				response = self.oauth_redirect(oauth_url, redirect_uri, e)
		return response


odonto_facebook_required_lazy = simplify_class_decorator(OdontoFacebookRequiredLazy)
예제 #2
0
    def execute_view(self, view_func, *args, **kwargs):
        try:
            result = view_func(*args, **kwargs)
        except TypeError, e:
            # this might be another error type error, raise it
            # the only way I know to check this is the message :(
            if 'graph' not in e.message:
                raise
            graph = kwargs.pop('graph', None)
            result = view_func(*args, **kwargs)
        return result


# decorators should look like functions :)
facebook_required = simplify_class_decorator(FacebookRequired)


class FacebookRequiredLazy(FacebookRequired):
    """
    Decorator which makes the view require the given Facebook perms,
    redirecting to the log-in page if necessary.

    Based on exceptions instead of a permission check
    Faster, but more prone to bugs

    Use this in combination with require_persistent_graph
    """
    def authenticate(self, fn, request, *args, **kwargs):
        redirect_uri = self.get_redirect_uri(request)
        oauth_url = get_oauth_url(
예제 #3
0
    def execute_view(self, view_func, *args, **kwargs):
        try:
            result = view_func(*args, **kwargs)
        except TypeError, e:
            # this might be another error type error, raise it
            # the only way I know to check this is the message :(
            if 'graph' not in e.message:
                raise
            graph = kwargs.pop('graph', None)
            result = view_func(*args, **kwargs)
        return result


# decorators should look like functions :)
facebook_required = simplify_class_decorator(FacebookRequired)


class FacebookRequiredLazy(FacebookRequired):
    """
    Decorator which makes the view require the given Facebook perms,
    redirecting to the log-in page if necessary.

    Based on exceptions instead of a permission check
    Faster, but more prone to bugs

    Use this in combination with require_persistent_graph
    """
    def authenticate(self, fn, request, *args, **kwargs):
        redirect_uri = self.get_redirect_uri(request)
        oauth_url = get_oauth_url(self.scope_list,