Karl_T Posted June 22, 2017 Share Posted June 22, 2017 register ajax code $email = $sanitizer->email($input->post->email); if($email){ $emailUser = $users->get("email=$email"); if (!$emailUser->id) { $password = $input->post->password; if (strlen($_POST["password"]) < 8) { return "length"; } $firstname = $sanitizer->text($input->post->firstname); $lastname = $sanitizer->text($input->post->lastname); $u = new User(); $u->name = $firstname.$lastname.uniqid(); $u->email = $email; $u->pass = $input->post->password; $u->firstName = $firstname; $u->lastName = $lastname; if($u->save()){ return "success"; } } else { return "duplicate"; } }else{ return "invalidemail"; } login ajax code $email = $sanitizer->email($input->post->email); if($email){ $emailUser = $users->get("email=$email"); //user login with email address if ($emailUser->id) { $u = $session->login($emailUser->name, $input->post->password); if ($u) { $user = $u; return "success"; } else { return "fail"; } } else { return "fail"; } } After users register an account and login with the above code, I get the follow error when executing the login ajax code. Notice: Trying to get property of non-object in /var/app/current/wire/core/PagesEditor.php on line 251 Notice: Trying to get property of non-object in /var/app/current/wire/core/PagesEditor.php on line 254 Notice: Trying to get property of non-object in /var/app/current/wire/core/PagesEditor.php on line 263 Notice: Trying to get property of non-object in /var/app/current/site/assets/cache/FileCompiler/site/modules/ProcessSetupPageName/ProcessSetupPageName.module on line 258 Notice: Trying to get property of non-object in /var/app/current/site/assets/cache/FileCompiler/site/modules/ProcessSetupPageName/ProcessSetupPageName.module on line 258 Notice: Trying to get property of non-object in /var/app/current/site/assets/cache/FileCompiler/site/modules/ProcessSetupPageName/ProcessSetupPageName.module on line 289 Fatal error: Uncaught Error: Call to a member function numChildren() on null in /var/app/current/wire/core/PagesEditor.php:270 Stack trace: #0 /var/app/current/wire/core/Pages.php(788): ProcessWire\PagesEditor->setupNew(Object(ProcessWire\NullPage)) #1 /var/app/current/wire/core/Wire.php(383): ProcessWire\Pages->___setupNew(Object(ProcessWire\NullPage)) #2 /var/app/current/wire/core/WireHooks.php(698): ProcessWire\Wire->_callMethod('___setupNew', Array) #3 /var/app/current/wire/core/Wire.php(442): ProcessWire\WireHooks->runHooks(Object(ProcessWire\Pages), 'setupNew', Array) #4 /var/app/current/wire/core/PagesEditor.php(465): ProcessWire\Wire->__call('setupNew', Array) #5 /var/app/current/wire/core/Pages.php(410): ProcessWire\PagesEditor->save(Object(ProcessWire\NullPage), Array) #6 /var/app/current/wire/core/Wire.php(386): ProcessWire\Pages->___save(Object(ProcessWire\NullPage), Array) #7 /var/app/current/wire/core/WireHooks.php(698): ProcessWire\Wire->_callMethod('___save', Array) #8 /var/app/current/wire/core/Wire.php(4 in /var/app/current/wire/core/PagesEditor.php on line 270 Error: Uncaught Error: Call to a member function numChildren() on null in /var/app/current/wire/core/PagesEditor.php:270 I have no idea why this is happening. The account is newly created from the register code with no error. After the error show, the account is actually logged in after a page reload. That means the $session->login is getting the correct arguments. The error messages do not show the exact line of code which fires the error. I use the same login to log in my superuser without error. The error occurs only when the user is newly created by the above code or by the admin panel. I can only find this similar case https://processwire.com/talk/topic/15204-cannot-login-errors-wirecorepageseditorphp/, but it seems not the same case. Any thoughts? Thanks in advance. Link to comment Share on other sites More sharing options...
Karl_T Posted June 23, 2017 Author Share Posted June 23, 2017 Sorry this is my own fault. The issue arouse because I have written a hook to 'login', editing some pages that do not exist in new account. 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