Advertisement
IzaacJ

FuelPHP - Auth::create_user?

Jun 9th, 2015
248
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.23 KB | None | 0 0
  1. // Internal server error when using this through jQuery AJAX.
  2. //
  3. // call:
  4. // $.ajax({
  5. //   type: "post",
  6. //   url: "api/signup.json",
  7. //   contentType: "application/x-www-form-urlencoded;charset=UTF-8",
  8. //   data: signupData, // serialized: username=ExampleUser&email=example%40example.tld&password=testpass
  9. //   dataType: "json",
  10. //   success: function(msg) {
  11. //     if('error' in msg) {
  12. //        alert(msg.error);
  13. //     }else {
  14. //        alert(msg.success);
  15. //     }
  16. //  },
  17. //  statusCode: {
  18. //     404: function() {
  19. //        alert('Kontakta webmastern dÃ¥ API:n ej verkar hittas!');
  20. //     }
  21. //  }
  22. // });
  23.  
  24. public function post_signup() {
  25.         $err = null;
  26.         try {
  27.             $ret = Auth::create_user(
  28.                 Input::post('username'),
  29.                 Input::post('password'),
  30.                 Input::post('email')
  31.             );
  32.         }catch(\SimpleUserUpdateException $e) {
  33.             $err = $e;
  34.         }
  35.             if (null !== $err) {
  36.                 return $this->response(array(
  37.                     'error' => $err
  38.                 ));
  39.             } else {
  40.                 return $this->response(array(
  41.                     'success' => $ret
  42.                 ));
  43.             }
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement