Sentry also uses the
protected static $loginAttribute = 'email';
To get the login data, check if you have made changes to it. Those are the lines that are giving you a hard time:
$loginName = $this->userProvider->getEmptyUser()->getLoginName();
$loginCredentialKey = (isset($credentials[$loginName])) ? $loginName : 'login';
Basically if $loginAttribute
is not available it will use 'login' as the credential key. So you can also test to give what it wants:
$credentials = array(
'email' => Input::get('email_or_username') ?: null,
'login' => Input::get('email_or_username') ?: null,
'password' => $this->input->get('password'),
);
Unfortunately, you cannot have two different fields to login your user, so if you need this you'll have to do your check manually, so you probably will be able to do something like:
public function login()
{
$user = $this->sentry->getUserProvider()->getEmptyUser();
$user = $user->where('email', $this->input->get('email_or_username'))
->orWhere('username', $this->input->get('email_or_username'))
->first();
try
{
if ($user && Hash::check($this->input->get('password'), $user->password)) /// here you check if a user was found
{
$this->sentry->login($user, false); /// remember = false /// here is the login happening in case of true
}
else
{
// user not found or wrong password
}
}
catch (\Exception $e)
{
return $this->redirect->to('login')->withErrors(array('login'=> $e->getMessage()));
}
}