public function postNewApiApplication() { $validation = new SeatApiAppValidator(); if ($validation->passes()) { // Lets go a quick look to see if this application // already exists in the database if (SeatApiApplication::where('application_name', Input::get('app_name'))->exists()) { return Redirect::back()->withInput()->withErrors('This application name is already in use. Please choose another.'); } // Create a new API Application $application = new SeatApiApplication(); $application->application_name = Input::get('app_name'); $application->application_ip = Input::get('app_src'); $application->application_login = str_random(8); $application->application_password = str_random(16); $application->save(); return Redirect::back()->with('success', 'The application has been saved!'); } else { return Redirect::back()->withInput()->withErrors($validation->errors); } }
| */ Route::filter('auth', function () { if (!\Auth::check()) { return Redirect::action('SessionController@getSignIn'); } }); Route::filter('auth.superuser', function () { if (!\Auth::check() || !\Auth::isSuperUser()) { return Redirect::to('/'); } }); // filter to check api app authentication Route::filter('auth.api', function ($route, $request) { // check for application that matches login, password and ip $user = \SeatApiApplication::where('application_login', '=', $request->getUser())->where('application_password', '=', $request->getPassword())->where('application_ip', '=', Request::getClientIp())->exists(); // if we cant find an app with those details, respond to the request if (!$user) { return Response::json(array('error' => true, 'message' => 'Invalid application credentials or request source.'), 401); } // also check to make sure that the request is over https if (!\Request::secure()) { return Response::json(array('error' => true, 'message' => 'API Access is only permitted via HTTPs.'), 401); } }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as