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


PHP Sentry::findUserByID方法代码示例

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


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

示例1: _check_system_groups

 /**
  * @param $id
  * @param $group_list
  * @return bool
  * @throws Cartalyst\Sentry\Users\UserNotFoundException
  */
 private static function _check_system_groups($id, $group_list)
 {
     try {
         $user = \Sentry::findUserByID((int) $id);
         $groups = $user->getGroups();
         foreach ($groups as $group) {
             if (!in_array($group['name'], $group_list)) {
                 continue;
             }
             return true;
         }
         return false;
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         throw new Cartalyst\Sentry\Users\UserNotFoundException($e->getMessage());
     }
 }
开发者ID:sgh1986915,项目名称:laravel-bizgym,代码行数:22,代码来源:GroupPermissions.php

示例2: post_register_mod_user

 public function post_register_mod_user()
 {
     $input = Input::all();
     $rules = array('first_name' => array('required'), 'last_name' => array('required'), 'birth_date' => array('required'), 'gender' => array('required'), 'email' => array('required', 'email', 'unique:users,email'), 'password' => array('required', 'min:6'), 'password_again' => array('required', 'min:6', 'same:password'));
     $messages = array('first_name.required' => 'Nome richiesto', 'last_name.required' => 'Cognome richiesto', 'birth_date.required' => 'Cognome richiesto', 'gender.required' => 'specificare sesso', 'email.required' => 'indirizzo e-mail richiesto', 'email.email' => 'inserisci un indirizzo e-mail valido', 'email.unique' => 'indirizzo e-mail già presente', 'password.required' => 'password necessaria', 'password_again.required' => 'È necessario ripetere la password', 'password_again.same' => 'Passoword non coincidenti');
     $validator = Validator::make($input, $rules, $messages);
     if ($validator->passes()) {
         try {
             $user = Sentry::findUserByID($input['user']['user_id']);
             $user->first_name = $input['user']['first_name'];
             $user->last_name = $input['user']['last_name'];
             $user->email = $input['user']['email'];
             $user->save();
             $users_data = Users_data::where('user_id', $input['user']['user_id'])->update($input['user_data']);
             return $this->make_response($input, false, array('Utente modificato correttamente'));
         } catch (\Exception $e) {
             return $this->make_response($input, true, array("errore non previsto: " . $e->getMessage() . "<br> File " . $e->getFile() . "<br> Line " . $e->getLine()));
         }
     }
     $errors = $validator->messages();
     return $this->make_response($input, true, $errors);
 }
开发者ID:lucabro81,项目名称:edutube,代码行数:22,代码来源:LoginController.php

示例3: update

 /**
  * Update the specified resource in storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function update($id = FALSE)
 {
     // Assign $id if FALSE
     if ($id === FALSE) {
         $id = $this->user->id;
     }
     // Check if self or admin
     if ($this->user['id'] == $id || $this->user->hasAccess('user.all')) {
         // Validate the create form
         $validator = Validator::make(Input::all(), array('first_name' => 'required', 'last_name' => 'required', 'company_name' => 'required', 'work_phone' => 'required', 'mobile_phone' => 'required', 'address' => 'required', 'city' => 'required', 'state' => 'required', 'zip' => 'required'));
         if ($validator->fails()) {
             return Redirect::back()->withInput()->withErrors($validator);
         } else {
             // Update UserDetail with Post Values
             try {
                 // Get the user
                 $user = Sentry::findUserByID($id);
                 // Update UserDetail
                 $user_detail = UserDetail::find($user->id);
                 $user_detail->first_name = Input::get('first_name');
                 $user_detail->last_name = Input::get('last_name');
                 $user_detail->company_name = Input::get('company_name');
                 $user_detail->address = Input::get('address');
                 $user_detail->address2 = Input::get('address2');
                 $user_detail->city = Input::get('city');
                 $user_detail->state = Input::get('state');
                 $user_detail->zip = Input::get('zip');
                 $user_detail->country = Input::get('country');
                 $user_detail->work_phone = Input::get('work_phone');
                 $user_detail->mobile_phone = Input::get('mobile_phone');
                 $user_detail->save();
                 // Only Admin users can update a user's groups
                 if ($this->user->hasAccess('user.all')) {
                     // Get groups
                     $group_client = Sentry::findGroupByName('client');
                     $group_staff = Sentry::findGroupByName('staff');
                     $group_admin = Sentry::findGroupByName('admin');
                     // Client group
                     if (Input::has($group_client->name)) {
                         if (!$user->inGroup($group_client)) {
                             $user->addGroup($group_client);
                         }
                     } else {
                         if ($user->inGroup($group_client)) {
                             $user->removeGroup($group_client);
                         }
                     }
                     // Staff group
                     if (Input::has($group_staff->name)) {
                         if (!$user->inGroup($group_staff)) {
                             $user->addGroup($group_staff);
                         }
                     } else {
                         if ($user->inGroup($group_staff)) {
                             $user->removeGroup($group_staff);
                         }
                     }
                     // Admin group
                     if (Input::has($group_admin->name)) {
                         if (!$user->inGroup($group_admin)) {
                             $user->addGroup($group_admin);
                         }
                     } else {
                         if ($user->inGroup($group_admin)) {
                             $user->removeGroup($group_admin);
                         }
                     }
                 }
                 Session::flash('alert_success', 'User Details Updated Successfully.');
                 return Redirect::to('/user/' . $user->id);
             } catch (Cartalyst\Sentry\Users\LoginRequiredException $e) {
                 Session::flash('alert_danger', 'User Details Update Failed.');
                 return Redirect::to('/dashboard');
             } catch (Cartalyst\Sentry\Users\UserExistsException $e) {
                 Session::flash('alert_danger', 'User Details Update Failed.');
                 return Redirect::to('/dashboard');
             } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
                 Session::flash('alert_danger', 'User not found.');
                 return Redirect::to('/dashboard');
             } catch (Cartalyst\Sentry\Groups\GroupNotFoundException $e) {
                 Session::flash('alert_danger', 'One of the User Groups was not found.');
                 return Redirect::to('/dashboard');
             }
         }
     } else {
         Session::flash('alert_danger', 'Access denied.');
         return Redirect::to('dashboard');
     }
 }
开发者ID:julianfresco,项目名称:documentHub,代码行数:95,代码来源:UserController.php

示例4: banUser

 public function banUser($id)
 {
     $user = Sentry::findUserByID($id);
     if (!$user->hasAccess('admin')) {
         try {
             // Find the user using the user id
             $throttle = Sentry::findThrottlerByUserId($id);
             // Ban the user
             $throttle->ban();
             return Redirect::to('/neverland')->with('global_success', 'User banned successfully banned.');
         } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
             return Redirect::to('/neverland')->with('global_error', 'There is no such user.');
         }
     } else {
         return Redirect::to('/neverland')->with('global_error', 'You can\'t ban Admin');
     }
 }
开发者ID:Belar,项目名称:eventpotion,代码行数:17,代码来源:UserController.php

示例5: function

<?php

Route::get('test', function () {
    // Find the user using the user id
    $user = Sentry::findUserByID(11);
    // Get the user permissions
    $permissions = $user->hasAccess('super');
    return json_decode($permissions);
});
Route::post('title-data/{type}/{provider}/{id}', 'TitleController@getData');
//search
Route::get(Str::slug(trans('main.search')), 'SearchController@byQuery');
Route::get('typeahead/{query}', array('uses' => 'SearchController@typeAhead', 'as' => 'typeahead'));
Route::post('populate-slider/{query}', 'SearchController@populateSlider');
Route::post('typeahead-actor/{query}', array('uses' => 'SearchController@castTypeAhead', 'as' => 'typeahead-cast'));
//homepage and footer
Route::get('/', array('uses' => 'HomeController@index', 'as' => 'home'));
Route::get(Str::slug(trans('main.contactUrl')), array('uses' => 'HomeController@contact', 'as' => 'contact'));
Route::post(Str::slug(trans('main.contactUrl')), array('uses' => 'HomeController@submitContact', 'as' => 'submit.contact'));
//news
Route::get('news/paginate', 'NewsController@paginate');
Route::resource(Str::slug(trans('main.news')), 'NewsController', array('names' => array('show' => 'news.show', 'index' => 'news.index', 'store' => 'news.store', 'edit' => 'news.edit', 'update' => 'news.update', 'destroy' => 'news.destroy', 'create' => 'news.create')));
Route::post('news/external', array('uses' => 'NewsController@updateFromExternal', 'as' => 'news.ext'));
//movies/series
Route::get('titles/paginate', 'TitleController@paginate');
Route::get('titles/relatedTo/{type}', 'TitleController@getRelatedToList');
Route::resource(Str::slug(trans('main.series')), 'SeriesController', array('names' => array('show' => 'series.show', 'index' => 'series.index', 'store' => 'series.store', 'edit' => 'series.edit', 'destroy' => 'series.destroy', 'create' => 'series.create'), 'except' => array('update')));
Route::resource(Str::slug(trans('main.movies')), 'MoviesController', array('names' => array('show' => 'movies.show', 'index' => 'movies.index', 'store' => 'movies.store', 'edit' => 'movies.edit', 'destroy' => 'movies.destroy', 'create' => 'movies.create'), 'except' => array('update')));
Route::post('detach-people', 'TitleController@detachPeople');
//seasons/episodes
Route::resource(Str::slug(trans('main.series')) . '.seasons', 'SeriesSeasonsController', array('except' => array('index', 'edit')));
开发者ID:onlystar1991,项目名称:mtdb,代码行数:31,代码来源:routes.php


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