I built a component where a user fills in a form, and on submit it creates an account for them and tries to log them in immediately. The account creation works, but when it tries to log users in, I get the error Invalid password
.
Here is the core the function:
$app = JFactory::getApplication();
$user = new JUser;
$user->bind($data);
if (!$user->save()) {
$this->setError($user->getError());
return false;
}
$credentials = array(
'username' => $user->username,
'password' => $user->password_clear,
);
$app->login($credentials);
I'm not entirely sure what I'm missing. When I do a print_r
of all of the data I have, it's all correct. If I log in manually after getting the wrong password error, I log in correctly. I tried passing $user->password
instead, but that didn't work either. If I modified index.php to do the exact same $app->login
, it would log me in properly.
Clearly there's something I'm missing, but I just can't find it.