Hello, Gael,
> class UrlPlugin(RedirectingFormPlugin):
> implements(IChallenger, IIdentifier)
>
> # IIdentifier
> def identify(self, environ):
> query = parse_dict_querystring(environ)
> if 'email' in query and 'secret' in query:
> rememberer = self._get_rememberer(environ)
> email = query['email']
> secret = query['secret']
> _secret = sha.new('%s:%s' % (email, rememberer.secret)).hexdigest()
> if secret == _secret:
> user = sql.one([Utilisateur.email,
> Utilisateur.password,
> Utilisateur.actif],
> sql.and_(Utilisateur.email==email,
> Utilisateur.actif==True))
> if user:
> login, password, actif = user[:]
> if actif:
> return {'login': login, 'password':password}
> return None
Technically this example does the same as
http://trac.sandbox.lt/auth/wiki/AuthFormMiddleware. Instead of
writing your plugin you would need to write isauthenticated function
that looks almost the same as identify function here. The differences
are:
1. AuthFormMiddleware does not have rememberer. Instead of that you
should use environ['beaker.session'].
2. Different return format. Most probably because of different
approach to identity.
What I like about your example is nice code reuse. However I doubt
that you will ever need to rewrite other functions from
RedirectingFormPlugin
--
Dalius
http://blog.sandbox.lt
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---