public function profile() { if ($this->getRequest()->getMethod() == 'POST') { $this->currentUser->setEmail($this->getParam('email')); $this->currentUser->setName($this->getParam('name')); $password = $this->getParam('password', ''); if (!empty($password)) { $this->currentUser->setHash(password_hash($password, PASSWORD_DEFAULT)); } $this->currentUser = $this->userStore->save($this->currentUser); $this->successMessage('Profile updated successfully!'); } $this->setTitle($this->currentUser->getName(), 'Edit Profile'); $form = new \Octo\Admin\Form(); $form->setMethod('POST'); $name = Form\Element\Text::create('name', 'Name', true); $name->setValue($this->currentUser->getName()); $email = Form\Element\Email::create('email', 'Email Address', true); $email->setValue($this->currentUser->getEmail()); $password = Form\Element\Password::create('password', 'Password (enter a new password to change)', false); $submit = new Form\Element\Submit(); $submit->setValue('Update Profile'); $submit->setClass('btn btn-success'); $form->addField($name); $form->addField($email); $form->addField($password); $form->addField($submit); $this->view->form = $form; }
public function resetPassword($userId, $key) { $user = $this->userStore->getById($userId); $userKey = md5(date('Y-m-d') . $user->getHash()); if (empty($user) || $key != $userKey) { $this->view->error = 'Invalid password reset request.'; return; } if ($this->request->getMethod() == 'POST') { $hash = password_hash($this->getParam('password'), PASSWORD_DEFAULT); $user->setHash($hash); $this->userStore->save($user); $_SESSION['user_id'] = $user->getId(); $this->redirect('/'); } $this->view->userId = $userId; $this->view->key = $key; return; }