本文整理汇总了PHP中Illuminate\Auth\AuthManager::attempt方法的典型用法代码示例。如果您正苦于以下问题:PHP AuthManager::attempt方法的具体用法?PHP AuthManager::attempt怎么用?PHP AuthManager::attempt使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Illuminate\Auth\AuthManager
的用法示例。
在下文中一共展示了AuthManager::attempt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: auth
/**
* Authenticate request.
*
* @return bool|exception
*/
public function auth()
{
if (!$this->auth->attempt($this->getCredentials())) {
throw new InvalidBasicAuthCredentials();
}
return true;
}
示例2: handle
/**
* Handle the command
*
* @param $command
* @throws InvalidCredentialsException
* @return mixed
*/
public function handle($command)
{
foreach ($this->availableIdentifiers() as $identifier) {
$attemptable = [$identifier => $command->identifier, 'password' => $command->password];
if ($this->authManager->attempt($attemptable, $command->remember)) {
return true;
}
}
$this->throwError();
}
示例3: login
/**
* @param $username
* @param $password
* @throws MissingInput
* @throws AuthenticationFailed
*/
public function login($username, $password)
{
$missing_fields = [];
if (!$username || $username === '') {
$missing_fields[] = 'username';
}
if (!$password || $password === '') {
$missing_fields[] = 'password';
}
if (count($missing_fields) > 0) {
throw new MissingInput($missing_fields);
}
if (!$this->auth->attempt(array('email' => $username, 'password' => $password))) {
throw new AuthenticationFailed();
}
}
示例4: handleLogin
public function handleLogin(AuthManager $auth, Request $request)
{
// Set the auth data
$userData = ['email' => $request->get('email'), 'password' => $request->get('password')];
// Log in successful
if ($auth->attempt($userData)) {
return redirect()->intended(route('home'))->with('message', 'You have been logged in.');
}
// Login failed
return redirect(route('auth.login'))->with('error', 'Your username or password was incorrect.');
}
示例5: postLogin
public function postLogin()
{
if ($this->auth->attempt($this->request->only('email', 'password'))) {
$url = $this->request->get("url");
if ($url == null) {
return $this->redirector->route("dashboard");
}
return $this->redirector->to($this->request->get("url"));
}
return $this->redirector->route('home');
}
示例6: login
/**
* Given correct credentials, log a user in.
*
* @param array $credentials
* @param boolean $remember
*
* @return bool
* @throws AuthenticationException
*/
public function login(array $credentials, $remember = false)
{
$credentials['is_active'] = 1;
// if the "eloquent-exceptions" driver is being used, an exception will
// be thrown if authentication failed. if one of the stock drivers are
// being used, it will just return false, and we have to throw the
// exception ourselves, with less information.
if (!$this->auth->attempt($credentials, $remember)) {
throw new AuthenticationException('Illuminate\\Auth\\Guard::attempt returned false');
}
$this->getCurrentUser()->rehashPassword($credentials['password']);
return true;
}
示例7: postIndex
/**
* Show the login form
*
* @return mixed
*/
public function postIndex()
{
// Pick up the honeypot field to stop bots, return to the login screen, no message
if ($this->request->get('potter')) {
return $this->redirect->to('auth/login')->withInput();
}
if (!$this->validator->with($this->request->all())->passes()) {
return $this->redirect->to('auth/login')->withErrors($this->validator->errors());
}
if ($this->auth->attempt(['username' => $this->request->get('username'), 'password' => $this->request->get('password')])) {
return $this->redirect->intended('/');
}
$this->session->flash('failed', trans('auth.incorrect_username_or_password'));
return $this->redirect->to('auth/login')->withInput();
}
示例8: run
public function run()
{
if (!$this->auth->attempt($this->credentials, $this->remember)) {
$this->addError('Invalid username / password combination');
}
}
示例9: login
public function login($email, $password, $remember = false)
{
return $this->auth->attempt(compact('email', 'password'), $remember);
}