opensupports/server/controllers/user/signup.php

36 lines
916 B
PHP
Raw Normal View History

<?php
2016-03-05 00:51:59 +01:00
class SignUpController extends Controller {
const PATH = '/signup';
2016-07-04 09:09:32 +02:00
private $email;
private $password;
2016-03-05 00:51:59 +01:00
public function handler() {
2016-07-04 09:09:32 +02:00
$this->requestUserData();
2016-03-05 00:51:59 +01:00
$userId = $this->createNewUserAndRetrieveId($this->email, $this->password);
Response::respondSuccess(array(
'userId' => $userId,
'userEmail' => $this->email
));
2016-07-04 09:09:32 +02:00
2016-07-04 20:47:28 +02:00
EmailSender::validRegister($this->email);
2016-07-04 09:09:32 +02:00
}
public function requestUserData(){
$this->email = Controller::request('email');
$this->password = Controller::request('password');
}
2016-04-05 01:00:39 +02:00
public function createNewUserAndRetrieveId($email, $password) {
2016-03-05 00:51:59 +01:00
$userInstance = new User();
$userInstance->setProperties(array(
'email' => $email,
'password' => Hashing::hashPassword($password)
2016-03-05 00:51:59 +01:00
));
return $userInstance->store();
2016-03-05 00:51:59 +01:00
}
}