Ok, that worked, thank you, new users are being created. I think the cookie thing is a non issue, now I need to feed the role column data into the session so I can check it for access control.
Regards Kenneth McLane 700 Locust St Systems Compliance Services Dubuque, 52001-6838 I1OB USA GTS Services Delivery Phone: +1-563-845-4674 Tie-Line: 946-4674 Mobile: +1-563-940-7147 e-mail: [email protected] "Ideas come from everything" -- Alfred Hitchcock From: Theodore Katseres <[email protected]> To: The elegant MVC web framework <[email protected]> Date: 05/30/2012 03:28 PM Subject: Re: [Catalyst] Need help inserting I'm not an expert but your check for existing user in the database should be ->find; ->search will return a resultset unless there is an exception. Also, you may want this instead. my $user = $c->model('authdb::User')->create({ username => $username }); $user->create_related('user_roles', {role=>'1'}); On Wed, May 30, 2012 at 3:09 PM, Kenneth S Mclane <[email protected]> wrote: I have my authentication working through the company LDAP server. I am attempting to check for the existence of the user in a sqlite table and add them and their role if they are not found. I do this during the login: if ($username && $password) { # Attempt to log the user in if ($c->authenticate({ username => $username, password => $password, } )) { # If successful, check the user table to see if they are there already if (! $c->model('authdb::User')->search( { 'username' => $username }, {})) { # If not add the user to the user table and the default role to the UserRole table $c->model('authdb::User')->create({ username => $username }); $c->model('authid::User')->create_related('user_roles', { user => 'user.id', role => '1', }); } # Then send them to the home page $c->response->redirect($c->uri_for($c->controller('Search')->action_for('search'))); return; } else { # Set an error message $c->stash(error_msg => "Bad username or password."); }; } else { # Set an error message $c->stash(error_msg => "Empty username or password.") unless ($c->user_exists); } # If either of above don't work out, send to the login page $c->stash(template => 'login.tt2'); } I have a couple of things I'm having trouble with, the user doesn't get created, I'm not sure I'm doing this correctly. Plus I had a co-worker log into the app on my computer and it picked up the session ID from the cookie. So I obviously need to do something about that, although normally anyone else would be logging in from a different system, right now it's in a vm on my computer. I know I'm getting closer, but I would appreciate some pointers to where I'm off here. _______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/ -- Ted Katseres ||=O=||_______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
<<image/gif>>
_______________________________________________ List: [email protected] Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst Searchable archive: http://www.mail-archive.com/[email protected]/ Dev site: http://dev.catalyst.perl.org/
