Everything registration-related happens here.
Example #1
0
 public function get_body()
 {
     $user = new RegistrationModel();
     if (isset($_GET)) {
         $user->confirm($_GET['hash']);
     }
     $this->display(['error' => $user->err]);
 }
 public function get_body()
 {
     $user = new RegistrationModel($_POST);
     $reg = $user->registration();
     if ($reg === TRUE) {
         $this->display(['error' => $user->err]);
     } else {
         $this->display(['name' => $user->name, 'login' => $user->login, 'email' => $user->email, 'error' => $user->err]);
     }
 }
 public function register_action()
 {
     $success = RegistrationModel::registerUser();
     if ($success) {
         Redirect::to('login/index');
     } else {
         Redirect::to('login/register');
     }
 }
Example #4
0
 /**
  * Verify user after activation mail link opened
  * @param int $user_id user's id
  * @param string $user_activation_verification_code user's verification token
  */
 public function verify($user_id, $user_activation_verification_code)
 {
     if (isset($user_id) && isset($user_activation_verification_code)) {
         RegistrationModel::verifyNewUser($user_id, $user_activation_verification_code);
         $this->View->render('register/verify');
     } else {
         Redirect::to('login/index');
     }
 }
Example #5
0
 public function new_account_action()
 {
     $newAccount = RegistrationModel::CreateNewAccount();
     if ($newAccount) {
         Teleport::to('account/log-in/');
     } else {
         Teleport::to('account/new-account/');
     }
 }
Example #6
0
 /**
  * Handles the entire registration process for DEFAULT users (not for people who register with
  * 3rd party services, like facebook) and creates a new user in the database if everything is fine
  *
  * @return boolean Gives back the success status of the registration
  */
 public static function registerNewUser()
 {
     // TODO this could be written simpler and cleaner
     // clean the input
     $user_name = strip_tags(Request::post('user_name'));
     $user_email = strip_tags(Request::post('user_email'));
     $user_password_new = Request::post('user_password_new');
     $user_password_repeat = Request::post('user_password_repeat');
     // stop registration flow if registrationInputValidation() returns false (= anything breaks the input check rules)
     if (Config::get('RECAPTCHA_ENABLED')) {
         $validation_result = RegistrationModel::registrationInputValidation(Request::post('g-recaptcha-response'), $user_name, $user_password_new, $user_password_repeat, $user_email);
     } else {
         $validation_result = RegistrationModel::registrationInputValidation(Request::post('captcha'), $user_name, $user_password_new, $user_password_repeat, $user_email);
     }
     if (!$validation_result) {
         return false;
     }
     // crypt the password with the PHP 5.5's password_hash() function, results in a 60 character hash string.
     // @see php.net/manual/en/function.password-hash.php for more, especially for potential options
     $user_password_hash = password_hash($user_password_new, PASSWORD_DEFAULT);
     // check if username already exists
     if (UserModel::doesUsernameAlreadyExist($user_name)) {
         Session::add('feedback_negative', Text::get('FEEDBACK_USERNAME_ALREADY_TAKEN'));
         return false;
     }
     // check if email already exists
     if (UserModel::doesEmailAlreadyExist($user_email)) {
         Session::add('feedback_negative', Text::get('FEEDBACK_USER_EMAIL_ALREADY_TAKEN'));
         return false;
     }
     // generate random hash for email verification (40 char string)
     $user_activation_hash = sha1(uniqid(mt_rand(), true));
     // write user data to database
     if (!RegistrationModel::writeNewUserToDatabase($user_name, $user_password_hash, $user_email, time(), $user_activation_hash)) {
         Session::add('feedback_negative', Text::get('FEEDBACK_ACCOUNT_CREATION_FAILED'));
     }
     // get user_id of the user that has been created, to keep things clean we DON'T use lastInsertId() here
     $user_id = UserModel::getUserIdByUsername($user_name);
     if (!$user_id) {
         Session::add('feedback_negative', Text::get('FEEDBACK_UNKNOWN_ERROR'));
         return false;
     }
     // send verification email
     if (RegistrationModel::sendVerificationEmail($user_id, $user_email, $user_activation_hash)) {
         Session::add('feedback_positive', Text::get('FEEDBACK_ACCOUNT_SUCCESSFULLY_CREATED'));
         return true;
     }
     // if verification email sending failed: instantly delete the user
     RegistrationModel::rollbackRegistrationByUserId($user_id);
     Session::add('feedback_negative', Text::get('FEEDBACK_VERIFICATION_MAIL_SENDING_FAILED'));
     return false;
 }
 public function confirm($hash)
 {
     if ($_SERVER['REQUEST_METHOD'] == 'GET') {
         $user = RegistrationModel::find_by_column('hash', $hash);
         if ($user->hash == $hash && $user->confirm == 0) {
             //если хеш из письма равен хешу из базы данных
             //активируем учетную запись
             $this->id = $user->id;
             $this->confirm = 1;
             if ($this->update() > 0) {
                 $this->err = 'Вы подтвердили учетную запись';
             }
         } elseif ($user->confirm == 1) {
             $this->err = 'Ваша учетная запись уже активирована';
         } else {
             $this->err = 'Неверная ссылка';
         }
     }
 }
 public function checkUserEmailReg()
 {
     if (RegistrationModel::checkUserEmail(Request::get_post('email'))) {
         echo 'Y';
     } else {
         echo 'N';
     }
 }
Example #9
0
<?php

require_once __DIR__ . '/../classes/Tools.php';
require_once __DIR__ . '/../classes/SessionWrapper.php';
Tools::startSession();
$userId1 = Request::get('id');
$code1 = Request::get('code');
if (empty($userId1) || empty($code1)) {
    // redirect to the home page
    header("HTTP/1.0 301 Moved Permanently");
    header("Location: " . Tools::getBaseUrl());
    exit;
}
SessionWrapper::clearFeedback();
$success = RegistrationModel::verifyNewUser($userId1, $code1);
$headerMeta = array('es' => array('title' => 'Activar cuenta'), 'en' => array('title' => 'Activate account'));
$headerResources = '
  <link href="' . Tools::getBaseUrl() . '/css/style-activar.css" rel="stylesheet" />';
require_once '../header.php';
?>

      <main class="text-center">
        <?php 
if ($success) {
    SessionWrapper::printFeedback(true);
} else {
    SessionWrapper::clearFeedback();
    if ($_SESSION['lang'] == 'en') {
        echo '<h3>Your email address could not be verified.</h3>';
        echo '<h3>Please try again or <a href="' . Tools::getBaseUrl(true) . '/acerca-de/">contact us</a>.</h3>';
    } else {