getLrsFromAuth() static public method

Gets the current LRS from the Authorization header.
static public getLrsFromAuth ( ) : Locker\Helpers\Lrs
return Locker\Helpers\Lrs
 /**
  * Constructs a new base controller.
  */
 public function __construct()
 {
     $this->lrs = Helpers::getLrsFromAuth();
     list($username, $password) = Helpers::getUserPassFromAuth();
     $this->client = Helpers::getClient($username, $password);
 }
Example #2
0
                throw new Exceptions\Validation($auth_validator->getErrors());
            }
        } else {
            if ($authorization !== null && strpos($authorization, 'Bearer') === 0) {
                $bridgedRequest = OAuth2\HttpFoundationBridge\Request::createFromRequest(Request::instance());
                $bridgedResponse = new OAuth2\HttpFoundationBridge\Response();
                if (!App::make('oauth2')->verifyResourceRequest($bridgedRequest, $bridgedResponse)) {
                    throw new Exceptions\Exception('Unauthorized request.', $bridgedResponse->getStatusCode());
                }
            } else {
                if ($authorization === null) {
                    throw new Exceptions\Exception('Unauthorized request.', 401);
                }
            }
        }
        $lrs = Helpers::getLrsFromAuth();
        //attempt login once
        if (!Auth::onceUsingId($lrs->owner_id)) {
            throw new Exceptions\Exception('Unauthorized request.', 401);
        }
    }
});
// Checks for super admin.
Route::filter('auth.super', function ($route, $request) {
    if (Auth::user()->role != 'super') {
        return Redirect::to('/');
    }
});
// Checks for LRS admin.
Route::filter('auth.admin', function ($route, $request) {
    $lrs = Lrs::find($route->parameter('lrs'));