mercredi 30 décembre 2015

Laravel Redirection doesn't work

I am using Laravel 5.1. My controller is specifically for admin users. So I check whether user is admin or not.This is my code.

public function getAdminData()
  {
    $this->checkAdminStatus();
    return response()->json(array('admin-data'));
  }
public function checkAdminStatus()
  {
    $userManager = new UserManager();
    if(!$userManager->isAdmin())
    {
        return redirect()->route('returnForbiddenAccess');
    }
  }

My route is

Route::any('api/app/forbidden',['uses' =>'ErrorController@returnNonAdminErrorStatus','as'=>'returnForbiddenAccess']);

Now if user is not admin, then it should not return admin-data yet it returns. Shouldn't it stop processing logic after redirect()->route call? Also this is purely REST application.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire