Firstly, in the database user table, you should add username field into it.
In your login function, you can do following to verify account by username or email:
$username = Input::get('username');
$password = Input::get('password');
$field = filter_var($username, FILTER_VALIDATE_EMAIL) ? 'email' : 'username';
try {
if (empty($username)) {
throw new Cartalyst\Sentry\Users\LoginRequiredException();
}
if (empty($password)) {
throw new Cartalyst\Sentry\Users\PasswordRequiredException();
}
$user = User::where($field, '=', $username)
->first();
if (empty($user)) {
throw new Cartalyst\Sentry\Users\UserNotFoundException();
}
if (!Hash::check($password, $user->password)) {
throw new Cartalyst\Sentry\Users\WrongPasswordException();
}
// Authenticate the user
Sentry::login($user, $remember);
}
catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
...
}
catch (Cartalyst\Sentry\Users\PasswordRequiredException $e) {
...
}
catch (Cartalyst\Sentry\Users\WrongPasswordException $e) {
...
}
catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
...
}
catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
...
}
With this way, we only access to database one time for user information.
Hope this help.