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


PHP Sentinel::getUserRepository方法代码示例

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


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

示例1: update

 /**
  * Processes the form.
  *
  * @return \Illuminate\Http\RedirectResponse
  */
 public function update()
 {
     $user = $this->currentUser;
     $rules = ['email' => "required|unique:users,email,{$user->email},email", 'password' => 'sometimes|required', 'password_confirm' => 'required_with:password|same:password'];
     $input = array_where(Input::get(), function ($key, $value) {
         if (str_contains($key, 'password') && empty($value)) {
             return false;
         }
         return true;
     });
     $validator = Validator::make($input, $rules);
     $validator->passes();
     $messages = $validator->errors();
     if ($messages->isEmpty()) {
         try {
             Sentinel::getUserRepository()->update($user, $input);
             return Redirect::route('user.edit_profile')->withSuccess('Your profile was successfully updated.');
         } catch (NotUniquePasswordException $e) {
             return Redirect::back()->withInput()->withErrors('This password was used before. You must choose a unique password.');
         }
     }
     return Redirect::back()->withInput()->withErrors($messages);
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:28,代码来源:AccountController.php

示例2: store

 /**
  * Register user
  *
  * Registers a new user
  *
  * @Post("/")
  * @Versions({"v1"})
  * @Transaction(
  *  @Request({"name": "foo", "email": "valid@email.com", "password": "someGoodPassword"}),
  *  @Response(200, body={"id":"1"}),
  *  @Response(422, body={"error": "existing", "field": "username|email", "message": "{field} already exists" }),
  *  @Response(422, body={"error": "format", "field": "username|email|password", "message": "Bad {field} format: {reason}" }),
  * )
  * @param \Dingo\Api\Contract\Http\Request $request
  * @return \Cartalyst\Sentinel\Users\UserInterface
  */
 public function store(RequestContract $request)
 {
     $data = $request->all();
     return $this->index();
     $users = \Sentinel::getUserRepository();
     try {
         if ($valid = $users->validForCreation($data)) {
             $user = $users->create($data);
             return $user;
         }
     } catch (InvalidArgumentException $e) {
         throw new BadRequestHttpException($e->getMessage());
     }
 }
开发者ID:RobinRadic,项目名称:testapi,代码行数:30,代码来源:UsersController.php

示例3: update_my_personal_profile_with_changes

 public function update_my_personal_profile_with_changes(FunctionalTester $I)
 {
     $I->am('Admin');
     $I->wantTo('update my profile and change some informations');
     $I->expectTo('see a success confirmation message and see that my data have changed');
     /***************************************************************************************************************
      * settings
      **************************************************************************************************************/
     // we create the admin role
     $admin_role = $this->_createAdminRole();
     // we attach it to the logged user
     $admin_role->users()->attach($this->_user);
     /***************************************************************************************************************
      * run test
      **************************************************************************************************************/
     $I->amOnPage('/');
     $I->amOnRoute('users.profile');
     $I->see(trans('users.page.title.profile'), 'h2');
     $I->selectOption('gender', config('user.gender_key.male'));
     $I->fillField('last_name', 'OTHER');
     $I->fillField('first_name', 'Other');
     $I->fillField('birth_date', '01/01/1999');
     $I->fillField('phone_number', '0101010101');
     $I->fillField('email', 'other@other.fr');
     $I->fillField('address', '1 impasse Commandant Cousteau');
     $I->fillField('zip_code', 99456);
     $I->fillField('city', 'Toulon');
     $I->fillField('country', 'Maroc');
     $I->fillField('password', 'password');
     $I->fillField('password_confirmation', 'password');
     $I->click(trans('global.action.save'));
     $I->seeCurrentRouteIs('users.profile');
     $I->see(trans('global.modal.alert.title.success'), 'h3');
     $I->see(trans('users.message.account.success'));
     $this->_user->fresh();
     $I->seeRecord('users', ['last_name' => 'OTHER', 'first_name' => 'Other', 'gender' => config('user.gender_key.male'), 'birth_date' => '1999-01-01', 'status_id' => $this->_user->status_id, 'board_id' => $this->_user->board_id, 'phone_number' => '+33 1 01 01 01 01', 'email' => 'other@other.fr', 'address' => '1 impasse Commandant Cousteau', 'zip_code' => 99456, 'city' => 'Toulon', 'country' => 'Maroc']);
     $I->seeRecord('role_users', ['user_id' => $this->_user->id, 'role_id' => Sentinel::findRoleBySlug('admin')->id]);
     $I->seeRecord('activations', ['user_id' => $this->_user->id, 'completed' => true]);
     $user = Sentinel::getUserRepository()->findByCredentials(['email' => 'other@other.fr']);
     $I->assertTrue(Hash::check('test', $user->password));
 }
开发者ID:Okipa,项目名称:una.app,代码行数:41,代码来源:UserCest.php

示例4: SetForgotPassword

 /**
  * Set the new password
  * @return $this
  */
 public function SetForgotPassword()
 {
     try {
         $user = \Sentinel::getUserRepository()->findById(\Input::get('UserId'));
         if (\Reminder::complete($user, \Input::get('ResetCode'), \Input::get('password'))) {
             return redirect('auth/login')->withErrors(array('login' => 'Password reset successful. Please Login'));
         } else {
             return redirect('auth/forgotpassword')->withErrors(array('forgot_password' => 'Password reset failed'));
         }
     } catch (\Exception $e) {
         return redirect('auth/forgotpassword')->withErrors(array('forgot_password' => 'User not found in our database.'));
     }
 }
开发者ID:brucewu16899,项目名称:Core,代码行数:17,代码来源:AuthController.php

示例5: __construct

 /**
  * Constructor.
  *
  * @return void
  */
 public function __construct()
 {
     parent::__construct();
     $this->users = Sentinel::getUserRepository();
     $this->roles = Sentinel::getRoleRepository();
 }
开发者ID:ryanrobertsname,项目名称:giftertipster.com,代码行数:11,代码来源:UsersController.php


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