Advertisement
Guest User

Untitled

a guest
Dec 19th, 2016
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.73 KB | None | 0 0
  1. AuthController.php
  2. public function postSignUp($request, $response)
  3. {
  4. $validation = $this->validator->validate($request, [
  5. 'first_name' => v::notEmpty()->Alpha(),
  6. 'last_name' => v::notEmpty()->Alpha(),
  7. 'username' => v::notEmpty()->noWhitespace()->UsernameAvailable()->length(3, 15),
  8. 'email' => v::notEmpty()->noWhitespace()->email()->EmailAvailable(),
  9. 'password' => v::notEmpty()->noWhitespace(),
  10.  
  11. 'password_verify' => v::notEmpty()->noWhitespace()->PasswordMatch(),
  12.  
  13. /*
  14. ->EmailAvailable() = custom created
  15. ->UsernameAvailable() = custom created
  16. ->PasswordMatch() = custom created
  17. */
  18. ]);
  19.  
  20. if ($validation->failed())
  21. {
  22. var_dump($validation);
  23. die();
  24. // return $response->withRedirect($this->router->pathFor('auth.signup'));
  25. }
  26.  
  27. $user = User::create([
  28. 'first_name' => $request->getParam('first_name'),
  29. 'last_name' => $request->getParam('last_name'),
  30. 'username' => $request->getParam('username'),
  31. 'email' => $request->getParam('email'),
  32. 'password' => password_hash($request->getParam('password'), PASSWORD_DEFAULT),
  33. ]);
  34.  
  35. $this->flash->addMessage('succes', 'You have been registered!');
  36.  
  37. return $response->withRedirect($this->router->pathFor('home'));
  38. }
  39.  
  40. <?php
  41.  
  42. protected $password;
  43.  
  44. public function __construct($password)
  45. {
  46. $this->password = $password;
  47. }
  48.  
  49.  
  50. public function Validate($input)
  51. {
  52. return password_verify($input, $this->password);
  53. }
  54.  
  55. <?php
  56.  
  57. public static $defaultTemplates = [
  58. self::MODE_DEFAULT => [
  59. self::STANDARD => "Password Doesn't Match",
  60. ],
  61. ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement