Skip to content

Instantly share code, notes, and snippets.

@skyleronken
Last active August 29, 2015 13:57

Revisions

  1. skyleronken revised this gist Mar 17, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion resources
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@
    self.method_check(request, allowed)

    if login_required and not self.Meta.authentication.is_authenticated(request): # This is the only change
    print request.user.is_authenticated()

    raise ImmediateHttpResponse(
    HttpUnauthorized('Log in required for this action')
    )
  2. skyleronken renamed this gist Mar 17, 2014. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions gistfile1.txt → resources
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # From within resources.py

    @wraps(func)
    def wrapper(self, request, *args, **kwargs):

  3. skyleronken created this gist Mar 17, 2014.
    12 changes: 12 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    @wraps(func)
    def wrapper(self, request, *args, **kwargs):

    if allowed is not None:
    self.method_check(request, allowed)

    if login_required and not self.Meta.authentication.is_authenticated(request): # This is the only change
    print request.user.is_authenticated()
    raise ImmediateHttpResponse(
    HttpUnauthorized('Log in required for this action')
    )
    return func(self, request, *args, **kwargs)