python - How do I log a user in using repoze.who? -
i have working repoze.who/what setup (on pylons app). want automatically log new users in after signup, without them having use login form. i've browsed repoze.who docs , source code and, maybe i'm missing it, can't find out how set logged-in user code, without new post request going through middleware. possible?
i have been similar issue morning , found: must know right there's 2 versions of repoze.who (1 , 2):
in v 1.x:
rememberer = request.environ['repoze.who.plugins']['cookie'] identity = {'repoze.who.userid': user.username} response.headerlist = response.headerlist + \ rememberer.remember(request.environ, identity)
in v 2.x (it's easier because provide , api):
from repoze.who.api import get_api who_api = get_api(request.environ) creds = {} creds['login'] = yourusername creds['password'] = yourpassword authenticated, headers = who_api.login(creds)
resources: v1: http://www.deanlee.cn/programming/repoze-who-perform-login-programmatically/ v2: http://docs.repoze.org/who/2.0/api.html
Comments
Post a Comment