即使登录凭据正确,Sentinel Authenticate也不会返回任何内容

时间:2017-11-15 05:47:08

标签: laravel-5.5 cartalyst-sentinel

请尝试使用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

0 个答案:

没有答案