Answer the question
In order to leave comments, you need to log in
How to implement REST authentication in laravel 4?
How to implement REST authentication in laravel 4?
The old project guide asks to translate to REST. There is the following:
Constructor
$this->beforeFilter(function() {
if(Request::format() == 'html') {
if (!Auth::check() ){
return Redirect::to('/login');
} else {
$this->user_id = Auth::user()->id;
$this->zipcode = Session::get('zipcode');
$this->store_id = Session::get('store_id');
$this->city = City::where('zipcode',$this->zipcode)->first();
$this->stores = DB::table('stores')
->leftJoin('store_locations','stores.id','=','store_locations.store_id')
->where('store_locations.zipcode',$this->zipcode)
->get();
$this->departments = Department::where('store_id',$this->store_id)->get();
$this->store = Store::find($this->store_id);
$this->cart_id = Session::get('cart_id');
}
} else {
$this->user_id = Input::get('user_id');
$token = Input::get('token'); // Initialize cart id as well
if(User::where('token','=',$token)->where('id', $this->user_id)->count() == 0 ){
$response_array = array('success' =>'false' , 'error_code' => '400', 'error' => 'Invalid Token');
$response_code = 200;
$response = Response::json($response_array , $response_code);
return $response;
}
}
} ,array('except' => array('login','verify','save','register','zipcode','social','forgot_password')));
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question