Guest User

Untitled

a guest
Feb 23rd, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. public function registerAction()
  2. {
  3. $postData = $this->request->getPost();
  4.  
  5. /*
  6. * Validation
  7. */
  8. $validation = new RegistrationValidation();
  9. $validationMessages = $validation->validate($postData);
  10.  
  11. if (count($validationMessages)) {
  12. // Validation Failed!
  13. foreach ($validationMessages as $message)
  14. $this->flashSession->error( $message);
  15. $this->response->redirect( $_SERVER['HTTP_REFERER'] );
  16. $this->response->send();
  17. } else {
  18. // Check Passwords Match
  19. if($postData['password'] !== $postData['password-repeat']) {
  20. $this->flashSession->error( "Passwords don't match");
  21. $this->response->redirect( $_SERVER['HTTP_REFERER'] );
  22. $this->response->send();
  23. }
  24. }
  25.  
  26. /**
  27. * Begin registration Process
  28. */
  29. $user = new Users();
  30.  
  31. $password = $this->request->getPost('pawword');
  32. $password = $this->security->hash($password);
  33.  
  34. $user->username = $this->request->getPost('username');
  35. $user->email = $this->request->getPost('email');
  36. $user->register_ip = $_SERVER['REMOTE_ADDR'];
  37. $user->password = $password;
  38. $user->active = 0;
  39.  
  40. // Store user
  41. $user->save();
  42. $this->view->emailmsg = $this->sendVerificationMail($user->id, $user->email, $user->username);
  43. }
  44.  
  45. public function loginAction()
  46. {
  47. if ($this->request->isPost()) {
  48.  
  49. $email = $this->request->getPost("email");
  50. $password = $this->request->getPost("password");
  51.  
  52. var_dump($password);
  53.  
  54. $user = Users::findFirstByEmail($email);
  55.  
  56.  
  57. var_dump($this->security->checkHash( 'edrsvc', '$2y$12$ZERPY2Q3N0hUdG1XSkw5V.DqhYek97IZyrRQwq/UP/X7xO3PiPIpG' ));
  58.  
  59. var_dump($this->security->checkHash($password, $user->password));
  60. var_dump(password_verify('edrsvc', '$2y$12$ZERPY2Q3N0hUdG1XSkw5V.DqhYek97IZyrRQwq/UP/X7xO3PiPIpG'));
  61.  
  62.  
  63.  
  64. die();
  65. if ($user) {
  66. if ($this->security->checkHash($password, $user->password)) {
  67.  
  68. var_dump($user);
  69. die();
  70.  
  71.  
  72. $this->_registerSession($user);
  73.  
  74. $this->flash->success(
  75. "Welcome " . $user->name
  76. );
  77.  
  78. // Forward to the 'invoices' controller if the user is valid
  79. $this->dispatcher->forward(
  80. [
  81. "controller" => "index",
  82. "action" => "index",
  83. ]
  84. );
  85. }
  86. } else {
  87.  
  88. $this->security->hash(rand());
  89.  
  90. $this->flashSession->error(
  91. 'Wrong Email or password <a href="#">Back</a>'
  92. );
  93.  
  94. }
  95. }
  96. }
Add Comment
Please, Sign In to add comment