本文整理汇总了PHP中Sentry::findThrottlerbyUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::findThrottlerbyUserId方法的具体用法?PHP Sentry::findThrottlerbyUserId怎么用?PHP Sentry::findThrottlerbyUserId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sentry
的用法示例。
在下文中一共展示了Sentry::findThrottlerbyUserId方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: function
/**
* Run all of our preflight tests and authenticate users
*/
Route::filter('snapi_auth', function ($route) {
// check to see if the model we're after actually exists
$model = str_singular($route->getParameter('model'));
if (class_exists($model)) {
// check to see if we have a valid API key
if (Input::has('api_key')) {
// now check to see if the api_key matches exactly one user in the database
if ($user = User::where('api_key', '=', Input::get('api_key'))->firstOrFail()) {
// check permissions
try {
$user = Sentry::getUserProvider()->findById($user->id);
$action = str_replace('ApiController@', '', $route->getAction());
$throttle = Sentry::findThrottlerbyUserId($user->id);
$banned = $throttle->isBanned();
$suspended = $throttle->isSuspended();
// if the user is activated, has access, and is not banned
if (!$user->isActivated()) {
// User account has not been activated
return Response::json(array('error' => 'Your user account has not been activated.'), 403);
} elseif ($banned) {
// Banned!
return Response::json(array('error' => 'Your account has been banned from having access to this resource.'), 403);
} elseif ($suspended) {
// Suspended!
$time = $throttle->getSuspensionTime();
$minutes = 1 == $time ? 'minute' : 'minutes';
return Response::json(array('error' => "Your account is suspended for {$time} {$minutes}."), 403);
} elseif (!$user->hasAccess("{$model}.{$action}")) {