本文整理汇总了PHP中App\Http\Controllers\Auth::verify方法的典型用法代码示例。如果您正苦于以下问题:PHP Auth::verify方法的具体用法?PHP Auth::verify怎么用?PHP Auth::verify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类App\Http\Controllers\Auth
的用法示例。
在下文中一共展示了Auth::verify方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: login
/**
* @param Request $request
* @return \Response
*/
public function login(Request $request)
{
if ($request->has('identifier') && $request->has('password')) {
switch (\Auth::verify(['identifier' => $request->get('identifier'), 'password' => $request->get('password')], $request->has('remember'))) {
case Verify::SUCCESS:
\Session::put('background', auth()->user()->background);
return redirect()->back()->with('success', 'Login successful');
case Verify::INVALID_CREDENTIALS:
return redirect()->back()->with('error', 'Invalid credentials');
case Verify::DISABLED:
$user = User::whereUsername($request->get('identifier'))->orWhere('email', $request->get('identifier'))->first();
if ($user->banend->eq(Carbon::create(0, 0, 0, 0, 0, 0))) {
return redirect()->back()->with('error', 'You are permanently banned for \'' . $user->banreason . '\'.');
}
// if ban expired unban and relogin.
if ($user->banend->lt(Carbon::now())) {
$user->banend = null;
$user->disabled = 0;
$user->banreason = null;
$user->save();
return $this->login($request);
}
return redirect()->back()->with('error', 'You are banned for another ' . $user->banend->diffForHumans(null, true) . '. Reason: \'' . $user->banreason . '\'');
case Verify::UNVERIFIED:
return redirect()->back()->with('error', 'Please verify your account');
}
}
return redirect()->back()->with('error', 'Missing credentials');
}
示例2: login
/**
* @param Request $request
* @return \Response
*/
public function login(Request $request)
{
if ($request->has('identifier') && $request->has('password')) {
switch (\Auth::verify(['identifier' => $request->get('identifier'), 'password' => $request->get('password')], $request->has('remember'))) {
case Verify::SUCCESS:
\Session::put('background', auth()->user()->background);
return redirect()->back()->with('success', 'Login successful');
case Verify::INVALID_CREDENTIALS:
return redirect()->back()->with('error', 'Invalid credentials');
case Verify::DISABLED:
return redirect()->back()->with('error', 'You are banned.');
case Verify::UNVERIFIED:
return redirect()->back()->with('error', 'Please verify your account');
}
}
return redirect()->back()->with('error', 'Missing credentials');
}