[Catalyst] Using dojo.io.bind to validate login

Matt S Trout dbix-class at trout.me.uk
Sat May 20 20:49:02 CEST 2006


Shawn Ferris wrote:
> Ok -- I am rather new to Catalyst and very new to Ajax.. I apologize up front if none of this makes any sense.
> 
> I've got a TT View that's configured with a wrapper.. My goal is to be able to display a login form on any page the user hits, if they're not already logged in. I'm using the dojo.Dialog widget to display the form so that it's modal. I've got everything working, except for the session mgmt.
> 
> My bind looks like this: 
> 
>     dojo.io.bind({
>       url: 'login',
>       handler: logonCallback,
>       content: {
>         username: dojo.byId('v_username').value,
>         password: dojo.byId('v_password').value
>       }
>     });
> 
> (on a side note -- I'm not using the formNode variation, which is a concern for me, but for some reason the params weren't making it back to catalyst.. I obviously would rather not see a plaintext password on the URL.. but at least it's working while I test and figure out what I'm doing wrong)
> 
> And my 'login' function is this:
> 
> sub login : Local {
>   my ( $self, $c ) = @_;
> 
>   my($username,$password)=(
>     $c->request->param('username'),
>     $c->request->param('password'),
>   );
> 
>   if(!$c->login($username,$password)) {
>     $c->res->body("LOGON_DENIED");
>   } else {
>     $c->res->body("LOGON_SUCCESSFUL");
>   }
> }
> 
> The session information is being checked/built correctly.. but now I'm stuck trying to get it back into a cookie for persistence. I'm assuming that I need to set the cookie information from my logonCallback, but I lack the know how. Can someone give me a pointer or two?

dojo.io.cookie may help you here. Also note that dojo.io.bind will take 
a 'headers:' hashref which will allow you to add a Cookie: header to the 
  AJAX request.



More information about the Catalyst mailing list