public function process($parameters)
 {
     $userManager = new UserManager();
     $validation = new Validation();
     //link na aktivaciu uctu
     if (isset($parameters[1])) {
         try {
             $userManager->activateUserAccount($parameters[0], $parameters[1]);
             $this->createMessage('Váš účet bol úspešne aktivovaný. Môžte pokračovať prihlásením', 'success');
             $this->redirect('prihlasenie');
         } catch (UserError $error) {
             $this->createMessage($error->getMessage(), 'warning');
         }
     }
     //ak bol odoslany formular s novou registraciou
     if ($_POST) {
         //odstranenie skodliveho kodu z antispam pola
         $captchaAnswer = strip_tags($_POST['captchaAnswer']);
         try {
             //validacia zadaneho uzivatelskeho mena
             $validUsername = $validation->checkUsername($_POST['name']);
             //ak bol spravne vyplneny antispam
             if ($validation->checkCaptcha($_POST['captchaNumber1'], $_POST['captchaNumber2'], $captchaAnswer)) {
                 $userManager->register($validUsername, $_POST['password'], $_POST['password2'], $_POST['email']);
                 $this->createMessage('Email pre aktiváciu účtu Vám bol úspešne zaslaný', 'success');
                 $this->redirect('prihlasenie');
             } else {
                 throw new UserError('Chybne vyplnený antispam');
             }
         } catch (UserError $error) {
             $this->createMessage($error->getMessage(), 'warning');
         }
     }
     //ak bol odoslany formular, zachovanie vyplneneho mena a emailu
     $this->data['name'] = '';
     if (isset($_POST['name'])) {
         $this->data['name'] = $_POST['name'];
     }
     $this->data['email'] = '@';
     if (isset($_POST['email'])) {
         $this->data['email'] = $_POST['email'];
     }
     $this->data['captcha'] = $validation->returnCaptcha();
     //antispam otazka
     $this->head['title'] = 'Registrácia';
     //title
     $this->view = 'registerForm';
     //sablona
 }
Esempio n. 2
0
 public function route($params)
 {
     $userManager = new UserManager();
     $user = $userManager->returnUser();
     if ($user) {
         $this->redirect("dashboard");
     }
     $header_menu = 'login_bar_none';
     $this->head['title_html'] = 'Registrace';
     if ($_POST) {
         $new_user = DBmodel::fromPOST(NewUser::class);
         // ověřím vyplnění zaslaných dat
         if ($new_user) {
             if (!filter_var($new_user->email, FILTER_VALIDATE_EMAIL)) {
                 $this->addMessage("Zadaný email má neplatný formát");
             } else {
                 if ($new_user->password != $new_user->password2) {
                     $this->addMessage("Zadaná hesla se neshodují");
                 } else {
                     $userManager = new UserManager();
                     $exist = $userManager->return_users_by_login($new_user->username);
                     if ($exist) {
                         $this->addMessage("Účet se zadaným loginem již existuje");
                     } else {
                         $userManager->register($new_user);
                         $this->addMessage("Registrace proběhla úspěšně, nyní se můžete přihlásit");
                         $this->redirect("login");
                     }
                 }
             }
         } else {
             $this->addMessage("Registrace selhala kvůli nevyplněným údajům");
         }
     } else {
         $_POST = NULL;
     }
     $this->header_menu = $header_menu;
     $this->view = 'registration';
 }
Esempio n. 3
0
 public function process($parameters)
 {
     //hlavicka stranky
     $this->head['title'] = 'Registrácia';
     if ($_POST) {
         $userManager = new UserManager();
         $validation = new Validation();
         try {
             //validacia zadaneho uzivatelskeho mena
             $validUsername = $validation->checkUsername($_POST['name']);
             $userManager->register($validUsername, $_POST['password'], $_POST['password2'], $_POST['email'], $_POST['year']);
             $this->createMessage('Boli ste úspešne zaregistrovaný.', 'success');
             $this->createMessage('Pokračujte tým, že sa prihlásite.', 'info');
             $this->redirect('prihlasenie');
         } catch (UserError $error) {
             $this->createMessage($error->getMessage(), 'warning');
             $this->redirect('registracia');
         }
     }
     //nastavenie sablony
     $this->view = 'registerForm';
 }
<?php

// Inicio la sesión
@session_start();
// Load user
require_once __DIR__ . '/../oop/manager/UserManager.php';
$userManager = new UserManager();
$USER = $userManager->loadSession();
// Check the login
if ($USER != null && $USER instanceof Supervisor) {
    $ID = $_POST['ID'];
    if ($userManager->userExists($ID)) {
        echo 'userAlreadyExists';
    } else {
        $PIN = $_POST['PIN'];
        $name = $_POST['name'];
        $email = $_POST['email'];
        $phone = $_POST['phone'];
        $tutor = new Tutor($ID, null, $name, $email, $phone);
        $tutor->setPIN($PIN);
        $userManager->register($tutor);
        echo 'true';
    }
} else {
    echo 'false';
}
Esempio n. 5
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
if (isset($_SESSION['loggedin'])) {
    $response = ["redirect" => "/index.php"];
} else {
    if (isset($_POST['email']) && isset($_POST['password']) && isset($_POST['verify']) && isset($_POST['blid'])) {
        require_once realpath(dirname(__DIR__) . "/class/UserManager.php");
        $email = $_POST['email'];
        $password = $_POST['password'];
        $password_check = $_POST['verify'];
        $blid = $_POST['blid'];
        //I don't think it is actually necessary to check csrf token for registration
        $response = UserManager::register($email, $password, $password_check, $blid);
    } else {
        $response = ["message" => "Form Incomplete."];
    }
}
return $response;
Esempio n. 6
0
 public function testRegisterFailPassword2()
 {
     $response = UserManager::register('*****@*****.**', 'asdf', 'fdsa', 'blid');
     $this->assertTrue(isset($response['message']));
     $this->assertEquals("Your passwords do not match.", $response['message']);
 }