/** * Define your route model bindings, pattern filters, etc. * * @param \Illuminate\Routing\Router $router * @return void */ public function boot(Router $router) { // /* |-------------------------------------------------------------------------- | Authentication Filters |-------------------------------------------------------------------------- | | The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ $router->filter('auth.basic', function () { return Auth::basic(); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ $router->filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); } }); parent::boot($router); }
function authenticationCheck() { $user = new \DB\SQL\Mapper($this->db, 'user'); $auth = new \Auth($user, array('id' => 'name', 'pw' => 'password')); $loginResult = $auth->basic(); return $loginResult; }
public function login() { $redirect = Session::get('redirect'); // check we're not already logged in if (!Auth::check()) { // do auth Auth::basic('username'); //check again if (Auth::check()) { // auth successful $user = Auth::user(); $user->touchLoggedInDate(); // update logged_in_at to current datetime Auth::login($user, true); // login and set remember_token } else { // auth failed $headers = array('WWW-Authenticate' => 'Basic'); $params = array('title' => 'Login failed', 'message' => 'Invalid username/password.'); Session::flash('redirect', $redirect); return Response::view('message', $params, 401, $headers); } } if ($redirect) { return Redirect::to($redirect); } else { return Redirect::home(); } }
function beforeRoute($f3, $params) { $user = new \DB\SQL\Mapper($f3->get('DB'), 'USERS'); $auth = new \Auth($user, array('id' => 'name', 'pw' => 'pass')); $loginStatus = $auth->basic(function ($pw) { return sha1($pw); }); if (!$loginStatus) { $f3->error(401); } }
public function reports() { Auth::basic('username'); if (!Auth::check()) { // do auth Auth::basic('username'); if (!Auth::check()) { return Response::make(View::make('unauth', array()), 401)->header('WWW-Authenticate', 'Basic'); } } Report::clearCache(); $reports = Report::select()->with('pathRecord', 'user')->orderBy('created_at', 'desc')->paginate(30); return View::make('reports', array('reports' => $reports, 'pageTitle' => 'Reports')); }
public function suggest() { Auth::basic('username'); if (!Auth::check()) { // do auth Auth::basic('username'); if (!Auth::check()) { return Response::make(View::make('unauth', array()), 401)->header('WWW-Authenticate', 'Basic'); } } $term = Input::get('term'); $result = Search::suggest($term); return Response::json($result); }
public function register() { $username = Input::get('username'); $password = Input::get('password'); if (!Auth::check()) { Auth::basic('username'); } $user = Auth::user(); if (!$user || !$user->hasSuper()) { return Response::json(array('result' => false, 'message' => 'Access denied')); } if (!User::usernameIsUnique($username)) { return Response::json(array('result' => false, 'message' => 'Username provided is already registered.')); } if ($username && $password) { User::register($username, $password); return Response::json(array('result' => true)); } else { return Response::json(array('result' => false, 'message' => 'Invalid details provided')); } }
public function recent() { Auth::basic('username'); if (!Auth::check()) { // do auth Auth::basic('username'); if (!Auth::check()) { return Response::make(View::make('unauth', array()), 401)->header('WWW-Authenticate', 'Basic'); } } $records = $this->getRecentRecords(); $paths = array(); $bucket = array(); $currentParent = null; foreach ($records as $record) { $path = Path::fromRelative($record->path); if ($path->exists()) { $path->record = $record; $parent = $path->getParent(); if ($currentParent === null) { $currentParent = $parent; } // if this path's parent is the same as the previous, add it to the bucket if ($parent->getHash() === $currentParent->getHash()) { $bucket[] = $path; } else { // if's different, add it to the paths array and start a new bucket $paths[] = array('parent' => $currentParent, 'paths' => $bucket); $bucket = array($path); $currentParent = $parent; } } } if (count($bucket) > 0) { $paths[] = array('parent' => $currentParent, 'paths' => $bucket); } return View::make('recent', array('pathBuckets' => $paths, 'pageTitle' => 'Recent uploads')); }
Validator::extend('map', 'EntityValidator@validateMap'); Validator::extend('location', 'EntityValidator@validateLocation'); Validator::extend('amenities', 'EntityValidator@validateAmenities'); Validator::extend('body', 'EntityValidator@validateBody'); Validator::extend('time', 'ReservationValidator@validateTime'); Validator::extend('customer', 'ReservationValidator@validateCustomer'); /* |-------------------------------------------------------------------------- | Require The Filters File |-------------------------------------------------------------------------- | | Next we will load the filters file for the application. This gives us | a nice separate location to store our route and application filter | definitions instead of putting them all in the main routes file. | */ require app_path() . '/filters.php'; Route::filter('auth.basic', function () { Config::set('auth.model', 'Cluster'); Auth::basic('clustername'); if (Auth::guest()) { return Response::json(array("success" => 0, "errors" => array(array("code" => 401, "type" => "Invalid credentials", "message" => "The credentials you provided are invalid."))), 401); } return; }); use Hautelook\Phpass\PasswordHash; use Illuminate\Auth\Guard; Auth::extend('flatturtle_phpass', function ($app) { $hasher = new PasswordHash(8, false); return new Guard(new FlatTurtleClusterProvider($hasher, 'Cluster'), $app['session.store']); });
| The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { if (Request::ajax()) { return Response::make('Unauthorized', 401); } else { return Redirect::guest('login'); } } }); Route::filter('auth.basic', function () { return Auth::basic('staff_username'); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); }
$f3->route('POST /ainesosa/valinta/poista', 'Ingredient->post_delete_ingredient'); # ATERIA AJAX $f3->route('GET /ajax/annos/haeAinesosat/@id/json', 'Meal->get_ingredients_json'); $f3->route('GET /ajax/annos/haeAinesosat/@id/json [ajax]', 'Meal->get_ingredients_json'); $f3->route('GET /ajax/annos/json', 'Meal->get_json'); # AINESOSA AJAX $f3->route('GET /ajax/ainesosa/json [ajax]', 'Ingredient->get_all_json'); $f3->route('GET /ajax/ainesosa/json', 'Ingredient->get_all_json'); # ALLERGIA AJAX $f3->route('GET /ajax/allergia/json', 'Allergy::ajax_map_to_id'); $f3->route('GET /ajax/allergia/json [ajax]', 'Allergy::ajax_map_to_id'); $f3->route('GET /login', function ($f3) { $user = new \DB\SQL\Mapper($f3->get('DB'), 'USERS'); $auth = new \Auth($user, array('id' => 'name', 'pw' => 'pass')); $loginStatus = $auth->basic(function ($pw) { return sha1($pw); }); if ($loginStatus) { $f3->reroute("/"); } else { $f3->error(401); } }); $f3->route('GET /logout', function ($f3) { echo print_r($_SESSION); $f3->clear('SESSION'); echo 'logged out'; }); #API ROUTES $f3->route('GET /api/annos/json', 'ApiController->get_meals'); $f3->route('GET /api/allergia/json', 'ApiController->get_allergies');
/** * Basic Authentication for login:password of developer * Check that the credentials match the database * Cache result for 60 seconds * @return boolean success/failure */ protected function basicAuthenticate($f3, $params) { $auth = new \Auth(new \DB\SQL\Mapper(\Registry::get('db'), '<TABLE>', array('login', 'password'), 60), array('id' => 'login', 'pw' => 'password')); return $auth->basic(function () use($auth, $f3) { }); }
*/ Route::filter('auth', function () { if (Auth::guest()) { if (Request::ajax()) { return Response::make('Unauthorized', 401); } else { return Redirect::guest('login'); } } }); Route::filter('auth.basic', function () { //return Auth::basic(); if (Input::get('fb')) { return Auth::basic("facebook_id"); } else { return Auth::basic("username"); } //return (Auth::basic("username")||Auth::basic("facebook_id")); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) {
| session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { if (Request::ajax()) { $sendMsgArray = array("ret_code" => -10052, "msg" => Lang::get('errormessages.-10052')); return Response::json($sendMsgArray); } else { return Redirect::guest('login'); } } }); Route::filter('auth.basic', function () { return Auth::basic('wy_user_name'); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); }
|-------------------------------------------------------------------------- | Authentication Filters |-------------------------------------------------------------------------- | | The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { return Redirect::guest('admin/login'); } }); Route::filter('auth.basic', function () { return Auth::basic('member_name'); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('admin'); }
| The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { if (Request::ajax()) { return Response::make('Unauthorized', 401); } else { return Redirect::guest('login'); } } }); Route::filter('auth.basic', function () { return Auth::basic('employee_username'); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); }
| The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { if (Request::ajax()) { return Response::make('Unauthorized', 401); } else { return Redirect::guest('login'); } } }); Route::filter('auth.basic', function () { return Auth::basic('email'); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); }
| The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ \Route::filter('auth', function () { if (\Auth::guest()) { if (\Request::ajax()) { return \Response::make('Unauthorized', 401); } else { return \Redirect::to('/'); } } }); \Route::filter('auth.basic', function () { return \Auth::basic(); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ \Route::filter('guest', function () { if (\Auth::check()) { return \Redirect::action('webmaster.index'); }
| The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { if (Request::ajax()) { return Response::make('Unauthorized', 401); } else { return Redirect::guest('/'); } } }); Route::filter('auth.basic', function () { return Auth::basic('user'); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); }
| The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { if (Request::ajax()) { return Response::make('Unauthorized', 401); } else { return Redirect::guest('login'); } } }); Route::filter('auth.basic', function () { return Auth::basic('username'); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); }
public function index($requestPath = '') { $path = Path::fromRelative('/' . $requestPath); if (!$path->exists()) { Auth::basic('username'); if (!Auth::check()) { // do auth Auth::basic('username'); if (!Auth::check()) { return Response::make(View::make('unauth', array()), 401)->header('WWW-Authenticate', 'Basic'); } } App::abort(404, 'Path not found'); } // if it's a file then download if ($path->isFile()) { return $this->download($path); } $path->loadCreateRecord($path); $children = $this->exportChildren($path); $orderParams = $this->doSorting($children); $groupedStaff = null; $genres = null; $categories = null; $userIsWatching = null; $pageTitle = null; $pageDescription = null; $pageImage = null; $relatedSeries = null; if ($series = $path->record->series) { $groupedStaff = $series->getGroupedStaff(); $genres = $series->getFacetNames('genre'); $categories = $series->getFacetNames('category'); $pageTitle = $series->name; $pageDescription = $series->description; if ($series->hasImage()) { $pageImage = $series->getImageUrl(); } $relatedSeries = $series->getRelated(); $user = Auth::user(); if ($user) { $userIsWatching = $user->isWatchingSeries($series); } } else { if (!$path->isRoot()) { $pageTitle = $path->getRelativeTop(); } } $params = array('path' => $path, 'groupedStaff' => $groupedStaff, 'genres' => $genres, 'categories' => $categories, 'breadcrumbs' => $path->getBreadcrumbs(), 'children' => $children, 'userIsWatching' => $userIsWatching, 'pageTitle' => $pageTitle, 'pageDescription' => $pageDescription, 'pageImage' => $pageImage, 'relatedSeries' => $relatedSeries); $params = array_merge($params, $orderParams); $updated = 0; foreach ($children as $child) { if (!$child->isDir && $child->rawTime > $updated) { $updated = $child->rawTime; } } $params['updated'] = $updated; if (Request::format() == 'atom' || Input::get('t') == 'atom') { return Response::make(View::make('index-atom', $params))->header('Content-Type', 'application/atom+xml; charset=UTF-8'); } else { if (Request::format() == 'rss' || Input::get('t') == 'rss') { return Response::make(View::make('index-rss', $params))->header('Content-Type', 'application/rss+xml; charset=UTF-8'); } else { Auth::basic('username'); if (!Auth::check()) { // do auth Auth::basic('username'); if (!Auth::check()) { return Response::make(View::make('unauth', array()), 401)->header('WWW-Authenticate', 'Basic'); } } return View::make('index', $params); } } }
| The following filters are used to verify that the user of the current | session is logged into this application. The "basic" filter easily | integrates HTTP Basic authentication for quick, simple checking. | */ Route::filter('auth', function () { if (Auth::guest()) { if (Request::ajax()) { return Response::make('Unauthorized', 401); } else { return Redirect::guest('login'); } } }); Route::filter('auth.basic', function () { return Auth::basic('user_id'); }); /* |-------------------------------------------------------------------------- | Guest Filter |-------------------------------------------------------------------------- | | The "guest" filter is the counterpart of the authentication filters as | it simply checks that the current user is not logged in. A redirect | response will be issued if they are, which you may freely change. | */ Route::filter('guest', function () { if (Auth::check()) { return Redirect::to('/'); }
App::before(function ($request) { Lang::setLocale(Session::get('language_id')); }); App::after(function ($request, $response) { // }); Route::filter('auth.toa', function () { }); Route::filter('auth', function () { if (Auth::guest()) { return Redirect::guest('/'); } }); Route::filter('auth.basic', function () { return Auth::basic("usuario"); }); Route::filter('hash', function () { $acceso = "\$PSI20\$"; $clave = "\$1st3m@\$"; $gestion_id = Input::get('gestion_id', ''); //$hash = Hash::make($acceso.$clave.$gestion_id); $hash = hash('sha256', $acceso . $clave . $gestion_id); $hashg = Input::get('hashg'); //Input::flash(); if ($hash != $hashg) { //return Response::json(array('not found'), 404); //return Redirect::to('/'); return $hash; } });
return Redirect::to('/'); } } }); Route::filter('admin', function () { if (Auth::user()->privilege != 1) { return Redirect::to('/'); } }); Route::filter('school', function () { if (Auth::user()->privilege != 2) { return Redirect::to('/'); } }); Route::filter('auth.basic', function () { return Auth::basic(); }); Route::filter('teacher', function () { if (Auth::user()->privilege != 3) { return Redirect::to('/'); } }); Route::filter('parent', function () { if (Auth::user()->privilege != 4) { return Redirect::to('/'); } }); /* |-------------------------------------------------------------------------- | Guest Filter |--------------------------------------------------------------------------
require __DIR__ . '/vendor/autoload.php'; define('ROOT', __DIR__); //F3::set('CACHE',TRUE); F3::set('DEBUG', 3); F3::set('UI', 'ui/'); F3::route('GET /', function () { $view = new View(); echo $view->render('gallery.htm'); }); F3::route('GET /admin', function () { F3::set('html_title', 'My Blog Administration'); $db = new \DB\Jig('data/'); $user = new \DB\Jig\Mapper($db, 'users.json'); $auth = new \Auth($user, array('id' => 'username', 'pw' => 'password')); $auth->basic(); if ($auth) { //set the session so user stays logged in F3::set('SESSION.user', $auth->name); F3::reroute('/admin/upload'); } else { F3::reroute('/admin'); } $view = new View(); echo $view->render('layout.htm'); }); F3::route('GET /admin/list', function () { (new app\controllers\GalleryController())->viewAll(); }); F3::route('GET /admin/upload', function () { F3::set('html_title', 'My Blog Create');