Php 更新配置文件密码laravel 5
我在laravel 5.1中工作,我的更新配置文件正常工作,但不会加密,现在无法工作。 当我尝试更新用户表时,还将出现密码确认字段,并导致数据库中发生冲突。我不明白。 表单中表示成功,但数据库未更新任何 代码Php 更新配置文件密码laravel 5,php,laravel-5,password-encryption,Php,Laravel 5,Password Encryption,我在laravel 5.1中工作,我的更新配置文件正常工作,但不会加密,现在无法工作。 当我尝试更新用户表时,还将出现密码确认字段,并导致数据库中发生冲突。我不明白。 表单中表示成功,但数据库未更新任何 代码 public function updatePassword() { $passwordData = Input::except('_token'); $validation = Validator::make($passwordData, User::$passwordD
public function updatePassword() {
$passwordData = Input::except('_token');
$validation = Validator::make($passwordData, User::$passwordData);
if ($validation->passes()) {
array_forget($passwordData,'password_confirmation');
User::where(array(
'password' => Hash::make(Input::get('password'))
));
Session::flash('password', 'Perfil editado com sucesso');
return Redirect::to('backend/perfil/password');
} else {
return Redirect::to('backend/perfil/password')->withInput()->withErrors($validation);
}
}
用户
public static $passwordData = array(
'password' => 'required|confirmed',
'password_confirmation' => 'required'
);
按照这个简单的步骤来摆脱任何东西 步骤1:从表单中获取密码
$PasswordData=Input::all()代码>
第2步:验证密码
Validator::extend('pwdvalidation', function($field, $value, $parameters) {
return Hash::check($value, Auth::user()->password);
});
步骤3:在用户
模型中定义验证规则
public static $rulespwd = array('OldPassword' => 'required|pwdvalidation',
'NewPassword' => 'required|confirmed|alphaNum|min:5|max:10',
'NewPassword_confirmation' => 'required',
);
注意:
您应根据需要定义自己的规则
步骤4:如果规则已通过,则update else会向视图中抛出错误消息
$validator = Validator::make($PasswordData, User::$rulespwd, $messages);
if ($validator->passes()) {
$user = User::find(Auth::user()->id);
$user->password = Input::get('NewPassword');
$user->save();
return Redirect::to(Session::get('urlpath') . '/changepassword')->withInput()->with('Messages', 'The Password Information was Updated');
} else {
return Redirect::to(Session::get('urlpath') . '/changepassword')->withInput()->withErrors($validator);
}
你有任何错误或密码不匹配吗?没有。总是说“成功”和我的密码不更新D{“id”:“2”,“密码”:“ola”}但不更新数据库:cif我采取行“array_忘记($passwordData,'password_confirmation”);”出现此错误SQLSTATE[42S22]:未找到列:1054“字段列表”中的未知列“密码确认”(SQL:updateusers
setid
=2,password
=hi,password\u confirmation
=2015-11-15 05:18:07其中password
=y$R/XBEDKN3xVWIKHFOxQI5G1QP/IR2LSCUHXUKNA5ZA.F9KGS)嗯,我需要为oldpassword创建一个字段?最终转到db现在需要加密它已经:)再次始终存在,谢谢:)你将保存我的项目以供大学xDWelcome,你现在还好吗?是的,在更新配置文件图片时丢失了调整大小和销毁图像:)明天我希望得到它