SteveB Posted June 24, 2013 Share Posted June 24, 2013 I'm using a login page based on Ryan's helpful post Stripping it down a bit this is what happens when submitting form to register a new user: $username = $sanitizer->username($input->post->username);$pass = $input->post->pass;$u = new User();$u->name = $username;$u->pass = $pass;$u->addRole('guest');$u->addRole('demo_viewer');$u->save(); $u = $session->login($input->post->user, $input->post->pass); $u = $session->login($username, $input->post->pass); This is the code for subitting a login form: if($user->isLoggedin()) $session->redirect('/profile/');if($input->post->username && $input->post->pass) { $username = $sanitizer->username($input->post->username); $pass = $input->post->pass; $u = $users->get($username); $u = $session->login($username, $pass);} Both cause this error when we do $session->login Error: Call to a member function has() on a non-object (line 47 of E:\dev\vhosts\pwb\wire\core\User.php) The user does get created and both roles do get added. $session is an object before we try $session->login Any ideas? Oh, I'm using PW 2.3.0 Dev version downloaded 5/15, if that matters. Edit: Fixed error Adrian spotted but it made no difference. Link to comment Share on other sites More sharing options...
adrian Posted June 24, 2013 Share Posted June 24, 2013 In the first code block you set $username, but then when you login, you use $input->post->user which according to the first line should at least be $input->post->username. Any reason you are not using $username here? Not sure what is wrong with the second block, but I'd be curious if that change to the first fixes it. Link to comment Share on other sites More sharing options...
Soma Posted June 24, 2013 Share Posted June 24, 2013 I get the same error when using custom login form no matter what. Even when using ProcessLogin execute to make the form. Link to comment Share on other sites More sharing options...
adrian Posted June 24, 2013 Share Posted June 24, 2013 I am using that script of Ryan's on a site without any problems, but it is using an older version of PW, so perhaps it is a new bug. Link to comment Share on other sites More sharing options...
SteveB Posted June 24, 2013 Author Share Posted June 24, 2013 I get the same error when using custom login form no matter what. Even when using ProcessLogin execute to make the form. Maybe it's me but I had a hard time finding a description of "normal" login practice on PW. That post of Ryan's seemed like the best overview. Will follow some other leads. Okay, the error goes away when I switch back to the production version. Unfortunately I need a feature from the dev version. Looking into that now. SOLVED: I downloaded the current dev version, dropped that in and that fixed it. The register form and the login form both work and the user is indeed logged in. Link to comment Share on other sites More sharing options...
Soma Posted June 24, 2013 Share Posted June 24, 2013 Yes the error doesn't occur with stable 2.3. What you mean with normal login practice? Is there also a non normal? The code Ryan posted is as good as it gets. A login is so simple and only one API call is needed to login. So it's not the script thats the problem but PW latest dev version. Link to comment Share on other sites More sharing options...
ryan Posted June 26, 2013 Share Posted June 26, 2013 SOLVED: I downloaded the current dev version, dropped that in and that fixed it. The register form and the login form both work and the user is indeed logged in. Just to confirm, the issue is, or is not, occurring in the latest dev version? Link to comment Share on other sites More sharing options...
SteveB Posted June 27, 2013 Author Share Posted June 27, 2013 Ryan: All good with the latest dev version. I had started this with the "stable" code and the Blog Profile. Then I realized I needed a feature from the dev version and I had a copy of dev that was about month old sitting on my hard drive. I dragged the wire folder over to my project. That gave me the feature I needed and mostly wortked but I had the non-object error. I downloaded a new copy of the dev version on 6/21, dragged the wire folder in and that fixed it. Soma: Re. "normal login practice" Having come to PW fairly recently I look for examples to see what the common idioms are. If I see similarity in how people go about a process, especially such a universal one as logging in, that tells me something. All I was saying is that I hadn't seen much on the topic until I found Ryan's post. P.S. I'm impressed with the high signal to noise ratio of this forum and PW itself. Link to comment Share on other sites More sharing options...
Soma Posted June 27, 2013 Share Posted June 27, 2013 Strange for me theres such an error only in the dev version. The stable works fine.. Link to comment Share on other sites More sharing options...
Soma Posted June 27, 2013 Share Posted June 27, 2013 Testing this again, I got the latest dev again with the session login throttle fix, and can't really say now what version it was and in what case. I only got it once after trying to login (custom login) when there's was a throttle of 10 seconds going. It would throw me the has() on a non object in user.php. But somehow it's gone in the dev. Since in stable 2.3 the session login throttle is now still broken, do you consider fixing it there too because it's an quite important feature security wise. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now