Skip to content

Instantly share code, notes, and snippets.

@ollieread
Forked from DB-009/Password change
Last active August 29, 2015 14:08
Show Gist options
  • Save ollieread/a3b712e574f74be8ece8 to your computer and use it in GitHub Desktop.
Save ollieread/a3b712e574f74be8ece8 to your computer and use it in GitHub Desktop.
if($validator->fails()){
return Response::json(['error' => 1,
'msg'=>$validator->errors()
]);
}
else{
$user = User::find(Input::get('user_id'));
$curpass = $user->password;
$pass = Hash::make(Input::get('password'));
$npass = Hash::make(Input::get('npassword'));
if(Hash::check($pass,$curpass)){
if(!Hash::check($curpass,$npass)){
$user ->password=Hash::make(Input::get('npassword'));
$user->save();
///SUCCESS
return Response::json(['success' =>1,'msg'=>'The user '.Input::get('username') .' has been updated!','action' => 'users/search_users']);
}
else{
return Response::json(['error' => 2,
'msg'=>'Cannot use Current password as New password']);
}
}
///FAILED
return Response::json(['error' => 3,
'msg'=>'The password you entered was incorrect']);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment