1

请尝试使用 sentinel 验证用户凭据,但代码似乎不起作用。

请尝试使用 sentinel 验证用户凭据,但代码似乎不起作用。

请提供任何帮助。

public function login(Request $request){
    /*
    return $request->all();
    gives me 

   {"_token":"cUPoDbVgoRBojkMS0J0kqOrqQttiDFqveOjPx6eh",
   "email":"test@gmail.com","p
   assword":"123456"}
   */
   try {
      if(Sentinel::Authenticate($request->all())){
        if(Sentinel::check()){
          $slug = Sentinel::getUser()->roles()->first()->slug;



          $notification = array(
                 'message' => 'Welcome Back!',
                 'alert-type' => 'success'
             );

              if($slug == 'admin'){
                return redirect('dashboard/admin')->with($notification);
              }
              elseif ($slug == 'manager') {
                return redirect('dashboard/manager')->with($notification);
              }
        }

          }
         else{

           $notification = array(
                  'message' => 'Invalid credentials',
                  'alert-type' => 'error'
              );
              return redirect()->back()->with($notification);
         }
    } catch (ThrottlingException $e) {
      $delay = $e->getDelay();

      $notification = array(
             'message' => 'You are suspended temporary',
             'alert-type' => 'error'
         );
         return redirect()->back()->with($notification);

     }catch (NotActivatedException $e) {
      $notification = array(
             'message' => 'You accout is not Activated yet',
             'alert-type' => 'error'
         );
         return redirect()->back()->with($notification);
    }

  }

我正在使用 laravel 5.5 和 sentinel 2.0

4

0 回答 0