Guest User

Untitled

a guest
Feb 9th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. public function post_recoverPass()
  2. {
  3. try
  4. {
  5. if ( empty($_POST['newpass']) || empty($_POST['repeatPass']))
  6. {
  7. $json = $this->response(array(
  8. 'code' => 400,
  9. 'message' => 'Existen campos vacíos',
  10. 'data' => []
  11. ));
  12. return $json;
  13. }
  14.  
  15. if(($_POST['newpass']) == ($_POST['repeatPass']))
  16. {
  17. $input = $_POST;
  18. $user = new Model_Users();
  19. $user->password = $input['newpass'];
  20. $user->save();
  21.  
  22. $json = $this->response(array(
  23. 'code' => 200,
  24. 'message' => 'Contraseña cambiada',
  25. 'data' => []
  26. ));
  27. return $json;
  28. }
  29. else
  30. {
  31. $json = $this->response(array(
  32. 'code' => 400,
  33. 'message' => 'Los campos no coinciden',
  34. 'data' => []
  35. ));
  36. return $json;
  37. }
  38. }
  39. catch (Exception $e)
  40. {
  41. $json = $this->response(array(
  42. 'code' => 500,
  43. 'message' => $e->getMessage()
  44. ));
  45. return $json;
  46. }
  47. }
Add Comment
Please, Sign In to add comment