本文整理汇总了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);
}
示例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());
}
}
示例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));
}
示例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.'));
}
}
示例5: __construct
/**
* Constructor.
*
* @return void
*/
public function __construct()
{
parent::__construct();
$this->users = Sentinel::getUserRepository();
$this->roles = Sentinel::getRoleRepository();
}