/**
* Fills a user with the given credentials, intelligently.
*
* @param \Cartalyst\Sentinel\Users\UserInterface $user
* @param array $credentials
* @return void
*/
public function fill(UserInterface $user, array $credentials)
{
$this->fireEvent('sentinel.user.filling', compact('user', 'credentials'));
$loginNames = $user->getLoginNames();
list($logins, $password, $attributes) = $this->parseCredentials($credentials, $loginNames);
if (is_array($logins)) {
$user->fill($logins);
} else {
$loginName = reset($loginNames);
$user->fill([$loginName => $logins]);
}
$user->fill($attributes);
if (isset($password)) {
$password = $this->hasher->hash($password);
$user->fill(compact('password'));
}
$this->fireEvent('sentinel.user.filled', compact('user', 'credentials'));
}