public function confirm(User $user, $code) { if ($user && $user->emailCode == $code) { $expired = substr($code, -10) + $this->config->email_code->exptime < time(); if (!$expired) { $user->save(['active' => 'Y', 'emailCode' => '']); $this->flash->success('Your account was activated'); return true; } } $this->flash->error('The given link is either invalid or expired'); return false; }
public function indexAction() { $form = new \Adiachenko\Project\Form\SignUpForm(); if ($this->request->isPost()) { if ($form->isValid($this->request->getPost())) { $user = new User(); $data = ['email' => $this->request->getPost('email'), 'passwordHash' => password_hash($this->request->getPost('password'), PASSWORD_BCRYPT), 'firstName' => $this->request->getPost('first-name'), 'middleName' => $this->request->getPost('middle-name'), 'lastName' => $this->request->getPost('last-name')]; if ($user->save($data)) { return $this->response->redirect('index'); } else { $this->showModelErrors($user, $form); } } else { $form->get('password')->setDefault(''); $form->get('password-confirm')->setDefault(''); } } $this->view->form = $form; }