/** * Change Password. * * Update the user's password on the RevTK site AND the corresponding PunBB forum account. * */ public function executePassword($request) { if ($request->getMethod() != coreRequest::POST) { return coreView::SUCCESS; } // handle the form submission $validator = new coreValidator($this->getActionName()); if ($validator->validate($request->getParameterHolder()->getAll())) { // verify old password $oldpassword = trim($request->getParameter('oldpassword')); $user = $this->getUser()->getUserDetails(); if ($user && $this->getUser()->getSaltyHashedPassword($oldpassword) == $user['password']) { // proceed with password update $new_raw_password = trim($request->getParameter('newpassword')); $user = $this->getUser()->getUserDetails(); // update the password on main site and forum $this->getUser()->changePassword($user['username'], $new_raw_password); // save username before signing out $this->username = $this->getUser()->getUserName(); // log out user (sign out, clear cookie, clear punbb cookie(not on staging website)) $this->getUser()->signOut(); $this->getUser()->clearRememberMeCookie(); if (coreContext::getInstance()->getConfiguration()->getEnvironment() !== 'staging' && coreConfig::get('app_path_to_punbb') !== null) { PunBBUsersPeer::signOut(); } try { // send email confirmation $mailer = new rtkMail(); $mailer->sendUpdatePasswordConfirmation($user['email'], $user['username'], $new_raw_password); } catch (coreException $e) { $request->setError('mail_error', 'Oops, we tried sending you a confirmation email but the mail server didn\'t respond. Your password has been updated though!'); } return 'Done'; } else { $request->setError('login_invalid', "Old password doesn't match."); } } // clear the password fields (avoid input mistakes) $request->setParameter('oldpassword', ''); $request->setParameter('newpassword', ''); $request->setParameter('newpassword2', ''); }
/** * Contact/Feedback Form page. * */ public function executeContact($request) { if ($request->getMethod() != coreRequest::POST) { return; } $validator = new coreValidator($this->getActionName()); if ($validator->validate($request->getParameterHolder()->getAll())) { $name_from = trim($request->getParameter('name')); $reply_to = trim($request->getParameter('email')); $message = trim($request->getParameter('message')); try { $mailer = new rtkMail(); $mailer->sendFeedbackMessage($reply_to, $name_from, $message); } catch (coreException $e) { $request->setError('smtp_mail', "I'm sorry, there was a problem sending the email. " . "Please try again shortly."); return; } return 'EmailSent'; } }