当前位置: 首页>>代码示例>>PHP>>正文


PHP Auth::verify方法代码示例

本文整理汇总了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');
 }
开发者ID:sirx,项目名称:w0bm.com,代码行数:33,代码来源:UserController.php

示例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');
 }
开发者ID:holzmaster,项目名称:w0bm.com,代码行数:21,代码来源:UserController.php


注:本文中的App\Http\Controllers\Auth::verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。