Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AuthController.php
- public function postSignUp($request, $response)
- {
- $validation = $this->validator->validate($request, [
- 'first_name' => v::notEmpty()->Alpha(),
- 'last_name' => v::notEmpty()->Alpha(),
- 'username' => v::notEmpty()->noWhitespace()->UsernameAvailable()->length(3, 15),
- 'email' => v::notEmpty()->noWhitespace()->email()->EmailAvailable(),
- 'password' => v::notEmpty()->noWhitespace(),
- 'password_verify' => v::notEmpty()->noWhitespace()->PasswordMatch(),
- /*
- ->EmailAvailable() = custom created
- ->UsernameAvailable() = custom created
- ->PasswordMatch() = custom created
- */
- ]);
- if ($validation->failed())
- {
- var_dump($validation);
- die();
- // return $response->withRedirect($this->router->pathFor('auth.signup'));
- }
- $user = User::create([
- 'first_name' => $request->getParam('first_name'),
- 'last_name' => $request->getParam('last_name'),
- 'username' => $request->getParam('username'),
- 'email' => $request->getParam('email'),
- 'password' => password_hash($request->getParam('password'), PASSWORD_DEFAULT),
- ]);
- $this->flash->addMessage('succes', 'You have been registered!');
- return $response->withRedirect($this->router->pathFor('home'));
- }
- <?php
- protected $password;
- public function __construct($password)
- {
- $this->password = $password;
- }
- public function Validate($input)
- {
- return password_verify($input, $this->password);
- }
- <?php
- public static $defaultTemplates = [
- self::MODE_DEFAULT => [
- self::STANDARD => "Password Doesn't Match",
- ],
- ];
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement