Due to the way my user authentication works, I'm rolling my own. It's
all work well, and I have it working with decorators, except for a
funny issue - when I raise a redirect_to from my decorator, Pylons
displays the error in debug mode, rather than actually redirecting.
In the debug I get a stack trace with "HTTPFound: 302 Found content-
type: text/html; charset=UTF-8 Content-Length: 0 location: /login/ "
Anyone have any idea? Or is there a better way to do this?
Auth.py:
from decorator import decorator
from pylons.controllers.util import abort, redirect_to
key = "user_id"
def _is_logged_in(session):
if key in session and session[key]:
return True
return False
def login_required(session, request=None):
def wrap(f):
print session
print request
if _is_logged_in(session):
return
redirect_to('login')
return wrap
My test action:
class PaymentController(BaseController):
@auth.login_required(session, request)
def index(self):
return 'Authenticated'
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---