Closed cshipley closed 9 years ago
I think this is the same problem as issue #2 . I have initiated a pull request #3 for this issue. are you certain that your email exists in Parse? It's caused by Parse returning an empty array in retrieveByCredentials. if you have a look at #3 you'll be able to see the code I used to fix this
public function retrieveByCredentials(array $credentials)
{
$username = $this->getUsernameFromCredentials($credentials);
$query = new ParseQuery('_User');
$query->equalTo('username', $username);
$user =$query->first(true);
if (!empty($user)){
return $user;
}
return null;
}
Can you try amending the retrieveByCredentials method in ParseUserProvider and see if it fixes the issue?
That code worked in that it wasn't crashing and correctly returned that the credentials were invalid.
It seems that my other problem was that the parse username must be the same as the email address. That is, when I changed the user name in parse to be the same as the email, it worked.
Yeah in my application I use email as username as well and so I extended the Registrar class and capture just the email during signup and then set the ParseUser email and username both to the email.
However as a test I changed my auth controller to validate the username instead of the email and changed my login form to ask for username and it works fine having a normal username in Parse, separate to the email. If you do that, you'd need to use your own implementation of the Registrar class which extends the LaraParse one and update your Auth controller to use that Registrar.
I'm not sure you would be able to do the login with username OR email thing because the Parse SDK requires you to login with username. There is a workaround but it's not very nice: https://www.parse.com/questions/allow-users-to-log-in-with-username-or-email
Using the email as user name is reasonable for this. Thanks for your help!
Is this the same issue as #2? Can this be closed?
Yes, I think so.
Is there something I'm doing wrong? Here is the stack trace:
in ParseUserProvider.php line 82
at HandleExceptions->handleError('4096', 'Argument 1 passed to LaraParse\Auth\ParseUserProvider::validateCredentials() must implement interface Illuminate\Contracts\Auth\Authenticatable, array given, called in /webdev/parse1/vendor/laravel/framework/src/Illuminate/Auth/Guard.php on line 383 and defined', '/webdev/parse1/vendor/hipsterjazzbo/laraparse/src/Auth/ParseUserProvider.php', '82', array()) in ParseUserProvider.php line 82
at ParseUserProvider->validateCredentials(array(), array('email' => 'spurious.thought@gmail.com', 'password' => 'password')) in Guard.php line 383
at Guard->hasValidCredentials(array(), array('email' => 'spurious.thought@gmail.com', 'password' => 'password')) in Guard.php line 364
at Guard->attempt(array('email' => 'spurious.thought@gmail.com', 'password' => 'password'), false) in AuthenticatesAndRegistersUsers.php line 79
at AuthController->postLogin(object(Request))