Ejemplo n.º 1
0
 public function activate()
 {
     $http = new Http();
     $id = $http->get('id');
     $date = $http->get('register');
     if (!empty($id) && !empty($date)) {
         $activation = new \models\Activation();
         if ($activation->check($id, $date)) {
             $user = new Users($id);
             $user->setActive();
             $user->writeData(true);
             Location::To(URL . 'success/success/Aktywacja powiodła się możesz teraz się zalogować.');
         } else {
             Location::To(URL . 'error');
         }
     } else {
         Location::To(URL . 'error');
     }
 }
Ejemplo n.º 2
0
 public function complete()
 {
     $http = new Http();
     $id = $http->get('id');
     $rand = $http->get('rand');
     $email = $http->get('email');
     if ($http->isActive('change')) {
         $id = $http->post('id');
         $rand = $http->post('rand');
         $email = $http->post('email');
     }
     if (!empty($id) && !empty($rand) && $email) {
         $pass = new \models\PasswordRecovery($email);
         if ($pass->checkUserToChange($id, $rand)) {
             if ($http->isActive('change')) {
                 $pass_1 = $http->post('password');
                 $pass_2 = $http->post('password_2');
                 $passVal = new \lib\PassVal("Nieprawidłowe hasło", "Hasła nie są takie same.", 5, 15);
                 $validator = new \lib\Validator(array('password' => $passVal, 'password_2' => $passVal));
                 if ($validator->validate($http->post())) {
                     $user = new Users($id);
                     $user->setPassword($pass_1);
                     $user->writeData(true);
                     $pass->deleteUserToChange($id);
                     $message = 'Twoje hało zostalo zmienione .';
                     Location::To(URL . 'success/success/' . $message);
                 } else {
                     $this->errors = $validator->getErrors();
                     $this->render('changepassword', array('categories' => $this->categories, 'd_product' => $this->d_product, 'id' => $id, 'rand' => $rand, 'email' => $email, 'errors' => $this->errors));
                 }
             }
             $this->render('changepassword', array('categories' => $this->categories, 'd_product' => $this->d_product, 'id' => $id, 'rand' => $rand, 'email' => $email));
         } else {
             Location::To(URL . 'error');
         }
     } else {
         Location::To(URL . 'error');
     }
 }