本文整理匯總了PHP中models\User::editUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::editUser方法的具體用法?PHP User::editUser怎麽用?PHP User::editUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類models\User
的用法示例。
在下文中一共展示了User::editUser方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: editProfile
public function editProfile(UserModel $user, $new_password)
{
$validator = new Validation();
$validator->setRule('required', $user->email);
$validator->setRule('required', $user->password);
$validator->setRule('email', $user->email);
if (!$validator->validate()) {
Redirect::back();
}
if ($this->user->editUser(Auth::getUserId(), $user->email, $new_password, $user->password) !== 1) {
Redirect::back();
}
Redirect::to('');
}
示例2: editProfile
public function editProfile(UserModel $user, $new_password)
{
$validator = new Validation();
$validator->setRule('required', $user->email, null, 'Email');
$validator->setRule('required', $user->password, null, 'Current Password');
$validator->setRule('email', $user->email, null, 'Email');
if (!$validator->validate()) {
Session::setError($validator->getErrors());
Redirect::back();
}
/* @var $user \Models\UserModel */
$userFromDb = $this->user->getUser(Auth::getUserId());
if (!Common::verifyPassword($user->password, $userFromDb->password)) {
Session::setError('Current password is not correct');
Redirect::back();
}
if ($this->user->editUser(Auth::getUserId(), $user->email, Common::hashPassword($new_password)) !== 1) {
Session::setError('Something is wrong. Try again.');
Redirect::back();
}
Session::setMessage('The profile is edited');
Redirect::to('');
}