Advertisement
Guest User

Untitled

a guest
Dec 10th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Controller;
  4.  
  5. use Model\User;
  6.  
  7. class AuthController extends Controller
  8. {
  9. public function register()
  10. {
  11. if($_POST["id"]!='' &&
  12. $_POST["name"]!='' &&
  13. $_POST["surname"]!='' &&
  14. $_POST["email"]!='' &&
  15. $_POST["password"]!='' &&
  16. $_POST["password_confirmation"]!=''
  17. )
  18. if($_POST["password"]!=$_POST["password_confirmation"])
  19. return "auth/register";
  20. else $this->store();
  21. else
  22. return "auth/register";
  23. }
  24.  
  25. public function confirmation_notice()
  26. {
  27. return "auth/confirmation_notice";
  28. }
  29.  
  30. public function store()
  31. {
  32. $user = new User($_POST["id"]);
  33. $user->name = $_POST["name"];
  34. $user->surname = $_POST["surname"];
  35. $user->email = $_POST["email"];
  36. $user->password = password_hash($_POST["password"],PASSWORD_BCRYPT);
  37. $user->password_confirmation = $_POST["password_confirmation"];
  38. $user->token = bin2hex(openssl_random_pseudo_bytes(16));
  39.  
  40. $this->getStorage()->store($user);
  41. header("location: /auth/confirmation_notice");
  42. }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement