当前位置: 首页>>代码示例>>PHP>>正文


PHP Sentry::findThrottlerByUserId方法代码示例

本文整理汇总了PHP中Sentry::findThrottlerByUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP Sentry::findThrottlerByUserId方法的具体用法?PHP Sentry::findThrottlerByUserId怎么用?PHP Sentry::findThrottlerByUserId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sentry的用法示例。


在下文中一共展示了Sentry::findThrottlerByUserId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionLogin

 /**
  * Login
  *
  * @AclMap(	name="auth_login_page",
  *			config={"only":"guest"},
  *			insufficient_message="acl.login",
  *			redirect={"type":"to","path":"/"})
  */
 public function actionLogin()
 {
     $this->viewData = array('title' => 'Sign In', 'auth_type' => 'sign-in');
     if (Request::instance()->getMethod() == 'POST' || Session::has('tmp_login')) {
         Input::flash();
         $validator = Validator::make(Input::all(), array('email' => 'required|email', 'password' => 'required'));
         if ($validator->fails()) {
             // Initial validation failed...
             $error = $validator->messages()->first();
         } else {
             // Initial validation success, continue...
             try {
                 // Find the user using the login credential
                 $email = Input::get('email', Session::get('tmp_login'));
                 $remember = (bool) Input::get('remember');
                 $user = Sentry::findUserByLogin($email);
                 // Check the password, dont get silly!
                 if (!$user->checkPassword(Input::get('password'))) {
                     $error = 'Incorrect password';
                 } else {
                     // Log the user in
                     $email = $user->email;
                     $password = Input::get('password');
                     $user = Sentry::authenticate(compact('email', 'password'), $remember);
                     // If it has connection, attach it
                     if (Session::has('connection')) {
                         $provider = Session::get('connection.type');
                         $data = new Collection(Session::get('connection.data'));
                         $connection = SocialConnection::create(array('user_id' => $user->id, 'provider' => $provider, 'provider_uid' => $data->get('id'), 'provider_username' => $data->get('username', $data->get('screen_name')), 'name' => $data->get('name'), 'data' => serialize($data->all())));
                         Session::forget('connection');
                     }
                     return Redirect::intended('/');
                 }
             } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
                 $error = 'Login field is required.';
             } catch (Cartalyst\Sentry\Users\UserNotActivatedException $e) {
                 Session::flash('activation', $user->email);
                 $error = 'User not activated.';
             } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
                 $error = 'User not found.';
             } catch (Cartalyst\Sentry\Throttling\UserSuspendedException $e) {
                 $throttle = Sentry::findThrottlerByUserId($user->id);
                 $time = $throttle->getSuspensionTime();
                 $error = "User is suspended for [{$time}] minutes.";
             } catch (Cartalyst\Sentry\Throttling\UserBannedException $e) {
                 $error = 'User is banned.';
             }
         }
         // Populate any errors
         if (isset($error)) {
             Session::flash('auth_errors', $error);
             return Redirect::route('auth_login');
         }
     }
     $this->setupLayout();
 }
开发者ID:sgh1986915,项目名称:laravel-bizgym,代码行数:64,代码来源:AuthController.php

示例2: isBanned

 public static function isBanned($id)
 {
     $throttle = Sentry::findThrottlerByUserId($id);
     if ($throttle->isBanned()) {
         // User is Banned
         return true;
     } else {
         // User is not Banned
         return false;
     }
 }
开发者ID:jrafaelca,项目名称:Doptor,代码行数:11,代码来源:User.php

示例3: getStatus

 /**
  * Get user's status
  */
 public function getStatus()
 {
     $throttle = Sentry::findThrottlerByUserId($this->id);
     if ($throttle->isBanned()) {
         return 'banned';
     } elseif ($throttle->isSuspended()) {
         return 'suspended';
     } else {
         return $this->isActivated() ? 'active' : 'not active';
     }
 }
开发者ID:sgh1986915,项目名称:laravel-bizgym,代码行数:14,代码来源:User.php

示例4: accountStatus

 public function accountStatus()
 {
     $throttle = Sentry::findThrottlerByUserId($this->id);
     if ($throttle->isBanned()) {
         return 'banned';
     } elseif ($throttle->isSuspended()) {
         return 'suspended';
     } else {
         return '';
     }
 }
开发者ID:ramonkampinga,项目名称:snipe-it,代码行数:11,代码来源:User.php

示例5:

                    <th>Username</th>
                    <th>First Name</th>
                    <th>Middle name</th>
                    <th>Last Name</th>
                    <th>Email</th>
                    <th>Type</th>
                    <!--<th>Branch</th>-->
                    <th>Brand</th>
                    <th>Active</th>
                    <th>Action</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($datas['users'] as $user)
                <?php 
$throttle = $throttle = Sentry::findThrottlerByUserId($user->getId());
?>
                
                <tr>
                    @if($currentUser->hasAccess('delete-user'))
                    <td style="text-align: center;">
                        <input type="checkbox" data-user-id="{{ $user->getId(); }}">
                    </td>
                    @endif     
                    <td>{{$user->getId();}}</td>
                    <td>{{$user->username}}</td>
                    <td>{{$user->first_name}}</td>
                    <td>{{$user->middle_name}}</td>
                    <td>{{$user->last_name}}</td>
                    <td>
                        <a rel="nofollow" href="javascript:void(0);">
开发者ID:leehanse,项目名称:smartadmin,代码行数:31,代码来源:c1-list-users.blade.php

示例6: unban

 /**
  * Unban the user.
  *
  * @return void
  */
 public function unban()
 {
     $throttle = \Sentry::findThrottlerByUserId($this->id);
     $throttle->unBan();
 }
开发者ID:rafaelvieiras,项目名称:connect,代码行数:10,代码来源:User.php

示例7: unbanUser

 public function unbanUser($id)
 {
     try {
         // Find the user using the user id
         $throttle = Sentry::findThrottlerByUserId($id);
         // Unban the user
         $throttle->unban();
         return Redirect::to('/neverland')->with('global_success', 'User UNbanned successfully.');
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::to('/neverland')->with('global_error', 'There is no such user.');
     }
 }
开发者ID:Belar,项目名称:eventpotion,代码行数:12,代码来源:UserController.php

示例8: manageUsers

 public function manageUsers($data)
 {
     if ($data['action'] == 'activate') {
         try {
             $userId = $data['id'];
             $user = \User::find($userId);
             $user->activated = true;
             $user->activated_at = date_create();
             $user->save();
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-activate:' . $e->getMessage());
             return false;
         }
     }
     if ($data['action'] == 'deactivate') {
         try {
             $userId = $data['id'];
             $user = \User::find($userId);
             $user->activated = false;
             $user->save();
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-deactivate:' . $e->getMessage());
             return false;
         }
     }
     if ($data['action'] == 'unsuspend') {
         try {
             $user = \Sentry::findThrottlerByUserId($data['id']);
             if ($suspend = $user->isSuspended()) {
                 $user->unsuspend();
             } else {
             }
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-unsuspend:' . $e->getMessage());
             return false;
         }
     }
     if ($data['action'] == 'suspend') {
         try {
             $user = \Sentry::findThrottlerByUserId($data['id']);
             if ($suspend = $user->isSuspended()) {
             } else {
                 $user->suspend();
             }
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-suspend:' . $e->getMessage());
             return false;
         }
     }
     if ($data['action'] == 'unbanned') {
         try {
             $user = \Sentry::findThrottlerByUserId($data['id']);
             if ($suspend = $user->isBanned()) {
                 $user->unBan();
             } else {
             }
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-unbanned:' . $e->getMessage());
             return false;
         }
     }
     if ($data['action'] == 'ban') {
         try {
             $user = \Sentry::findThrottlerByUserId($data['id']);
             if ($suspend = $user->isBanned()) {
             } else {
                 $user->ban();
             }
             return true;
         } catch (\Exception $e) {
             \Log::error('Something Went Wrong in User Repository - manageUsers()-ban:' . $e->getMessage());
             return false;
         }
     }
 }
开发者ID:ymnl007,项目名称:92five,代码行数:80,代码来源:UserRepository.php

示例9: ban_user

 public function ban_user($id = FALSE)
 {
     if ($this->user->hasAccess('user.all')) {
         // Check $id is set
         if ($id === FALSE || !is_numeric($id)) {
             Session::flash('alert_warning', 'Routing Error. Please try your request again.');
             return Redirect::to('dashboard');
         } else {
             try {
                 // Find the user using the user id
                 $throttle = Sentry::findThrottlerByUserId($id);
                 // Ban the user
                 $throttle->ban();
                 Session::flash('alert_success', 'User was banned.');
                 return Redirect::to('/user');
             } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
                 Session::flash('alert_danger', 'Banning Failed. User was not found. Please try again.');
                 return Redirect::to('/user');
             }
         }
     } else {
         Session::flash('alert_danger', 'Access denied.');
         return Redirect::to('dashboard');
     }
 }
开发者ID:julianfresco,项目名称:documentHub,代码行数:25,代码来源:UserController.php

示例10: manage

 public function manage($dash, $id, $mode)
 {
     switch ($mode) {
         case 'view':
             $theme = Theme::uses('dashboard')->layout('default');
             $view = array('name' => 'Dashboard User', 'id' => $id);
             $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Users', 'url' => Setting::get('system.dashurl') . '/users'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/user/1/view']]);
             $theme->setTitle(Setting::get('system.adminsitename') . ' User');
             $theme->setType('User');
             return $theme->scope('user.view', $view)->render();
             break;
         case 'edit':
             if (Sentry::getUser()->inGroup(Sentry::findGroupByName('admin'))) {
                 $theme = Theme::uses('dashboard')->layout('default');
                 $view = array('name' => 'Dashboard User', 'id' => $id);
                 $theme->breadcrumb()->add([['label' => 'Dashboard', 'url' => Setting::get('system.dashurl')], ['label' => 'Users', 'url' => Setting::get('system.dashurl') . '/users'], ['label' => $id, 'url' => Setting::get('system.dashurl') . '/user/1/edit']]);
                 $theme->setTitle(Setting::get('system.adminsitename') . ' User');
                 $theme->setType('User');
                 return $theme->scope('user.edit', $view)->render();
             } else {
                 return "NOT AUTHORISED";
             }
             break;
         case 'delete':
             $user = Sentry::getUser();
             // Find the Administrator group
             $admin = Sentry::findGroupByName('admin');
             // Check if the user is in the administrator group
             if ($user->inGroup($admin)) {
                 $deleteuser = Sentry::findUserById($id);
                 $usergroup = $deleteuser->getGroups();
                 $usergroupe = json_decode($usergroup, true);
                 $usergroupe[0]['pivot']['group_id'];
                 $group = Sentry::findGroupById($usergroupe[0]['pivot']['group_id']);
                 $groupname = $group->name;
                 if ($groupname == 'teachers') {
                     Teacher::findOrFail($id)->delete();
                 } elseif ($groupname == 'students') {
                     Student::findOrFail($id)->delete();
                 }
                 $deleteuser->delete();
                 return Redirect::to(URL::previous());
             } else {
                 return "UNAUTHORISED ACTION";
             }
             break;
         case 'suspend':
             $user = Sentry::getUser();
             // Find the Administrator group
             $admin = Sentry::findGroupByName('admin');
             // Check if the user is in the administrator group
             if ($user->inGroup($admin)) {
                 $throttle = Sentry::findThrottlerByUserId($id);
                 // Suspend the user
                 $throttle->suspend();
                 return Redirect::to(URL::previous());
             } else {
                 return "UNAUTHORISED ACTION";
             }
             break;
         case 'unsuspend':
             $throttle = Sentry::findThrottlerByUserId($id);
             // Suspend the user
             $throttle->unsuspend();
             return Redirect::to(URL::previous());
             break;
         case 'ban':
             $user = Sentry::getUser();
             // Find the Administrator group
             $admin = Sentry::findGroupByName('admin');
             // Check if the user is in the administrator group
             if ($user->inGroup($admin)) {
                 $throttle = Sentry::findThrottlerByUserId($id);
                 // Suspend the user
                 $throttle->ban();
                 return Redirect::to(URL::previous());
             } else {
                 return "UNAUTHORISED ACTION";
             }
             break;
         case 'unban':
             $throttle = Sentry::findThrottlerByUserId($id);
             // Suspend the user
             $throttle->unban();
             return Redirect::to(URL::previous());
             break;
     }
 }
开发者ID:eufelipemartins,项目名称:edlara,代码行数:88,代码来源:UserController.php

示例11: un_ban

 public function un_ban($id)
 {
     $user = Sentry::findThrottlerByUserId($id);
     $user->unBan();
     return Redirect::back()->withSuccess('User un-banned');
 }
开发者ID:shinichi81,项目名称:Nifty-Newsletter,代码行数:6,代码来源:UserController.php

示例12: getUsers

 /**
  * @brief gets all users
  *
  * @return Mixed
  */
 public function getUsers()
 {
     $users = \Sentry::findAllUsers();
     foreach ($users as $user) {
         $throttle = \Sentry::findThrottlerByUserId($user->id);
         $user['suspended'] = $throttle->isSuspended();
         $user['banned'] = $throttle->isBanned();
         $user['activated'] = $user->isActivated();
     }
     return $users;
 }
开发者ID:arikazukitomaharjan,项目名称:OfficeSystem,代码行数:16,代码来源:UserController.php

示例13: destroy

 /**
  * Remove the specified resource from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($lang, $id)
 {
     /*
     $user = Sentry::findUserById($id);
     $user->delete();
     */
     try {
         $throttle = Sentry::findThrottlerByUserId($id);
         if ($banned = $throttle->isBanned()) {
             $throttle->unBan();
             Session::flash('message', trans('kuu-validation.user_was_unbanned_successfully'));
         } else {
             $throttle->ban();
             Session::flash('message', trans('kuu-validation.user_was_banned_successfully'));
         }
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         Session::flash('error_message', trans('kuu-validation.user_was_not_found') . ' ' . $id);
     }
     //return Redirect::to('/admin/user?search_string='.Input::get('search_string').'&page='.Input::get('page'));
     return Redirect::route('admin.user', array('lang' => App::getLocale(), 'search_string' => Input::get('search_string'), 'page' => Input::get('page')));
 }
开发者ID:jinxiao8942,项目名称:laravel-kuu,代码行数:27,代码来源:AdminUserController.php

示例14: catch

          <td>{{ $user['user_info']['city'] }}, {{ $user['user_info']['state'] }} {{ $user['user_info']['zip'] }}</td>
        </tr>
        <tr>
          <th>Work Phone</th>
          <td>{{ $user['user_info']['work_phone'] }}</td>
        </tr>
        <tr>
          <th>Mobile Phone</th>
          <td>{{ $user['user_info']['mobile_phone'] }}</td>
        </tr>
        <tr>
          <th>Activated</th>
          <td>
            <?php 
try {
    if (Sentry::findThrottlerByUserId($user->id)->isBanned()) {
        ?>
                  <span class="text-danger">Banned</span> <?php 
    } else {
        ?>
                  @if( $user['activated'] == 1 )
                    <span class="text-success">Active</span>
                  @else
                    <span class="text-danger">Not Active</span>
                  @endif <?php 
    }
} catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
    Log::error(date("Y-m-d H:i:s") . '- RuntimeException in app/views/auth/user_show.blade.php: ' . $e);
}
?>
          </td>
开发者ID:julianfresco,项目名称:documentHub,代码行数:31,代码来源:user_show.blade.php

示例15: array

 case 'auth.register':
     $user = $param;
     // As default, we will assign user group
     $user->addGroup(Sentry::findGroupByName('User'));
     // Log activity
     Event::fire('log.user_activity', array(Logger::LOW, $user->id, array(array('sub_type' => 'auth.register', 'detail' => '%s signed up', 'icon' => 'icon-user', 'deletable' => 0, 'value' => $param))));
     break;
 case 'auth.check_acl':
     // Here we'll get the current request instance
     // thus allowing us to check and dynamically assign roles
     $request = $param;
     // This is initial implementation, as we just check login state
     if (Auth::check()) {
         // If it already login, we will assign 'user'
         $roles = array('user');
         $throttle = Sentry::findThrottlerByUserId(Auth::user()->id);
         if ($throttle->isBanned()) {
             // Nothing we can do about it... :(
             $roles = array('banned');
         } else {
             // Let see their system roles
             foreach (Auth::user()->getGroups() as $group) {
                 $roles[] = strtolower($group->name);
             }
         }
         if ($param instanceof Illuminate\Http\Request) {
             if ($param->is('user/profile')) {
                 // Assign 'me' role
                 $roles[] = 'me';
             }
         }
开发者ID:sgh1986915,项目名称:laravel-bizgym,代码行数:31,代码来源:events.php


注:本文中的Sentry::findThrottlerByUserId方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。