Exemplo n.º 1
0
<?php

/*
|--------------------------------------------------------------------------
| Application & Route Filters
|--------------------------------------------------------------------------
|
| Below you will find the "before" and "after" events for the application
| which may be used to do any work before or after a request into your
| application. Here you may also register your custom route filters.
|
*/
App::before(function ($request) {
    // Ensure remember-me valid across both sentry and L4 auth
    if (!Auth::check()) {
        $userArray = Sentry::getCookie()->get();
        if ($userArray && (list($id, $persistCode) = $userArray)) {
            $caller = User::find($id);
            if ($caller && $caller->checkPersistCode($persistCode)) {
                // They are remembered people!
                Sentry::login($caller, true);
            }
        }
    }
    // Respect testing-stub data
    if ($request->getSessionStore()->has('roles') && App::environment() == 'testing') {
        // Here we could set useful setting for corresponding stub
        // for now we let it empty
    } else {
        // In regular request, we will monitoring their roles on each request
        $roles = Event::fire('auth.check_acl', array($request));