本文整理汇总了PHP中Illuminate\Auth\AuthManager::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthManager::validate方法的具体用法?PHP AuthManager::validate怎么用?PHP AuthManager::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Auth\AuthManager
的用法示例。
在下文中一共展示了AuthManager::validate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: handle
/**
* Handle the command.
*
* @param $command
*
* @throws \Tectonic\Shift\Modules\Authentication\Exceptions\InvalidAuthenticationCredentialsException
* @throws \Tectonic\Shift\Modules\Authentication\Exceptions\UserAccountAssociationException
* @return \Illuminate\Auth\UserInterface|null
*/
public function handle($command)
{
// First check to see if the users credentials are valid.
$userCredentialsAreValid = $this->authenticate->validate(['email' => $command->email, 'password' => $command->password]);
// If user credential are invalid, throw exception.
if (!$userCredentialsAreValid) {
throw new InvalidAuthenticationCredentialsException();
}
// Find out if user has an account id with the current account
$accountUser = $this->userRepository->getByEmailAndAccount($command->email, CurrentAccount::get());
// If an account user is found, login and return user
if ($accountUser) {
$this->authenticate->login($accountUser, $command->remember);
$user = $this->authenticate->getUser();
// Raise an event, and dispatch
$this->raise(new UserHasAuthenticated($user));
$this->eventDispatcher->dispatch($this->releaseEvents());
return $user;
}
// Login failed, throw exception
throw new UserAccountAssociationException();
}