login_handler

131 views
Skip to first unread message

shaw1ea

unread,
Jul 8, 2009, 4:56:13 PM7/8/09
to TurboGears
Where is the login_handler method located in the source code for tg2?
I am trying to implement post logon url so that the user is directed
to an appropriate page after they log in. How do I specify which page
the user will get directed to based on their username and password.
The users permissions must be used to determine the proper page. Can
someone explain this or direct me to an example that show how to do
this?

Sanjiv Singh

unread,
Jul 9, 2009, 9:43:12 AM7/9/09
to turbo...@googlegroups.com
Have a look at the post_login method of RootController. Change the
last few lines to

userid = request.identity['repoze.who.userid']
if came_from.decode() == '/':
came_from = tg.url(get_userpage(userid))
flash(....)
redirect(came_from)

get_userpage should contain your page access logic and return a url
string based on userid

regards
Sanjiv

zhan zou

unread,
Nov 20, 2012, 2:48:42 AM11/20/12
to turbo...@googlegroups.com
I got this question the same with you, do anybody know the true source code location for tg2?

Michael Pedersen

unread,
Jan 2, 2013, 1:00:33 AM1/2/13
to tg-trunk
I'm not sure why this is considered a mystery.

The default login handler is located at MYAPP.controllers.root:RootController.login
The default login form is located at MYAPP/templates/login.html
The default login form handler (once authentication is completed by repoze.who) is located at MYAPP.controllers.root:RootController.post_login

The means of controlling authentication and authorization are determined by repoze.who and repoze.what, respectively. The documentation for those two packages covers the needed steps on how to customize them. While that documentation can be difficult to understand (I've tried, and it's not easy for me), it is there, and does cover how to customize them.

If there's something I've missed, please follow up on this, and I'll try to answer then.


--
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/-/8BSWGRaIPcUJ.
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.



--
Michael J. Pedersen
My Online Resume: http://www.icelus.org/ -- Google+ http://plus.ly/pedersen
Google Talk: m.ped...@icelus.org -- Twitter: pedersentg
Reply all
Reply to author
Forward
0 new messages