Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Controller;
- use Model\User;
- class AuthController extends Controller
- {
- public function register()
- {
- if($_POST["id"]!='' &&
- $_POST["name"]!='' &&
- $_POST["surname"]!='' &&
- $_POST["email"]!='' &&
- $_POST["password"]!='' &&
- $_POST["password_confirmation"]!=''
- )
- if($_POST["password"]!=$_POST["password_confirmation"])
- return "auth/register";
- else $this->store();
- else
- return "auth/register";
- }
- public function confirmation_notice()
- {
- return "auth/confirmation_notice";
- }
- public function store()
- {
- $user = new User($_POST["id"]);
- $user->name = $_POST["name"];
- $user->surname = $_POST["surname"];
- $user->email = $_POST["email"];
- $user->password = password_hash($_POST["password"],PASSWORD_BCRYPT);
- $user->password_confirmation = $_POST["password_confirmation"];
- $user->token = bin2hex(openssl_random_pseudo_bytes(16));
- $this->getStorage()->store($user);
- header("location: /auth/confirmation_notice");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement