login hook

1 view
Skip to first unread message

Randall

unread,
Mar 7, 2006, 12:32:46 PM3/7/06
to TurboGears
I need to perform some actions after a successful login, but it's not
clear to me how to do this. In the included login form, the data is
posted to the resource last viewed and handled by tg identity. I don't
see an opportunity in this process to act upon the login. Any ideas
are appreciated.

Randall

Jeff Watkins

unread,
Mar 7, 2006, 1:52:09 PM3/7/06
to turbo...@googlegroups.com
That's not an unreasonable request.

Any suggestions from the TG community?

--
Jeff Watkins
http://newburyportion.com/


Patrick Lewis

unread,
Mar 7, 2006, 2:15:15 PM3/7/06
to TurboGears
One idea is to modify the standard login form. Store the
${previous_url} in a hidden form field, and set the action for the form
to be a url that will test if the user is authenticated (just test if
identity.current.anonymous). If they are authenticated, do your magic,
and then forward on to the ${previous_url}, regardless if the user
authenticated or not. If they did authenticate, great. If they didn't,
they will just get the login form again.

Not really a hook, but should get the job done.

Randall

unread,
Mar 7, 2006, 4:38:02 PM3/7/06
to TurboGears
That works nicely.

Randall

Jorge Vargas

unread,
Mar 9, 2006, 11:22:30 PM3/9/06
to turbo...@googlegroups.com
how about a method in identity class that executes at the end, the equivalent of a html onclick event + javascript call (in concept of course)

Jeff Watkins

unread,
Mar 10, 2006, 7:51:38 AM3/10/06
to turbo...@googlegroups.com
Can you give me a better explanation? Maybe a pseudocode example?

On 9 Mar, 2006, at 11:22 pm, Jorge Vargas wrote:

> how about a method in identity class that executes at the end, the
> equivalent of a html onclick event + javascript call (in concept of
> course)

--
Jeff Watkins
http://newburyportion.com/


Jorge Vargas

unread,
Mar 10, 2006, 11:53:48 AM3/10/06
to turbo...@googlegroups.com
Sorry I haven't use identity I just read about it in here that's why I didn't write some code like thing.

Looking at the trac for identity i believe the best place will be to add a

field to identity.SecureResource and went you subclass it(to make your secured pages) you will say something like 

class Toxicologia(controller.Controller
, identity.SecureResource):
required_permissions= ["write"]
required_groups = ["admin"]
allowed_hosts = ["127.0.0.1"]
identity_required = True
onLogin=self.myMethod
then declare it.

then inside the Identity framework after the validation is done check for onLogin method which of course will be declared as empty.

that makes sence?



as a param to login object (soprovider i think) you will send in a method defined in your controller or none. That method will be executed by the identity framework if you had a success login.
Reply all
Reply to author
Forward
0 new messages