How to use authentication provided by repoze.who/what in TurboGears2.1?

36 views
Skip to first unread message

Cosmia Luna

unread,
Jan 29, 2012, 10:37:43 AM1/29/12
to turbo...@googlegroups.com
I'm new to TurboGears and switched from Django before, though Django works well.

In a nutshell, how to get a User instance by email and password like Django does, and log he/she in?

How does repoze processing to check if a user is logged in or not? How can I tell repoze how to determine identified or not? And how to log a user in?

Of course I can manually check the database, manually set the cookies and session ... but I think it's a better way to use the repoze, maybe. 

I read many documentations ( including the repoze.who/what's documentation, of course ), and get a lot of not-very-useful-by-now knowledge, but don't know how to do that.

I use TurboGears 2.1

Thanks

Cosmia Fu

Alessandro Molina

unread,
Feb 2, 2012, 3:51:49 AM2/2/12
to turbo...@googlegroups.com
What you are looking for is probably:

response.headers =
request.environ['repoze.who.plugins']['main_identifier'].remember(request.environ,
{'repoze.who.userid':user_name})

The user_name variable is the User.user_name field in a standard TG2
configuration.

For a more structured function to use take a look at
http://stackoverflow.com/questions/4576486/turbogears-change-user-via-function-calls/6636220#6636220

> --
> You received this message because you are subscribed to the Google Groups
> "TurboGears" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/turbogears/-/HK0csGomKugJ.
> To post to this group, send email to turbo...@googlegroups.com.
> To unsubscribe from this group, send email to
> turbogears+...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/turbogears?hl=en.

Reply all
Reply to author
Forward
0 new messages