public function executeEmail(sfWebRequest $request) { $this->user = PcUserPeer::getLoggedInUser(); $this->form = new EditEmailForm(); $fields = array(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('email')); if ($this->form->isValid()) { $fields = $request->getParameter('email'); if (PcUserPeer::emailExist($fields['email1'])) { $loginLink = sfContext::getInstance()->getController()->genUrl('@login'); $forgottenPasswordLink = sfContext::getInstance()->getController()->genUrl('@forgotten-password'); $this->getUser()->setFlash('email_wrong', __('ACCOUNT_SETTINGS_EMAIL_EXISTS_ERROR')); } else { $user = PcUserPeer::getLoggedInUser(); // logging this change $emailChange = new PcEmailChangeHistory(); $emailChange->setUserId($user->getId()); $emailChange->setOldEmail($user->getEmail()); $emailChange->setNewEmail($fields['email1']); $emailChange->save(); $user->setEmail($fields['email1']); $user->save(); sfContext::getInstance()->getEventDispatcher()->notify(new sfEvent('userSetEmail', 'user.set_email', array('user' => $user))); $this->getUser()->setFlash('settingSuccess', __('ACCOUNT_SETTINGS_EMAIL_RESET_SUCCESS')); $this->forward('settings', 'index'); } } } }
public function executeForgottenPassword(sfWebRequest $request) { // if the user is authenticated, they shouldn't get here PcUtils::redirectLoggedInUser($this->getUser(), $this); $this->form = new PasswordForgottenForm(); if ($request->isMethod('post')) { $this->form->bind($request->getParameter('passwordForgotten')); if ($this->form->isValid()) { $fields = $request->getParameter('passwordForgotten'); $email = $fields['email']; if (PcUserPeer::emailExist($email)) { CustomAuth::sendPasswordForgotten($email); $this->redirect('customAuth/passwordForgottenThankYou'); } else { $registrationLink = sfContext::getInstance()->getController()->genUrl('@registration'); $forgottenPasswordLink = sfContext::getInstance()->getController()->genUrl('@forgotten-password'); // the requested email doesn't exist! $this->getUser()->setFlash('password_forgotten_wrong', sprintf(__('WEBSITE_FORGOTTEN_PSW_EMAIL_ADDRESS_NOT_REGISTERED_ERROR'), $forgottenPasswordLink, $registrationLink)); } } } }
* Licensed under the AGPL version 3 license. * * * Danyuki Software Limited is registered in England and Wales (Company No. 07554549) * ************************************************************************************** * Plancake is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU Affero General Public License for more details. * * * * You should have received a copy of the GNU Affero General Public License * * along with this program. If not, see <http://www.gnu.org/licenses/>. * * * **************************************************************************************/ require_once dirname(__FILE__) . '/../../config/ProjectConfiguration.class.php'; $configuration = ProjectConfiguration::getApplicationConfiguration('account', 'prod', false); $context = sfContext::createInstance($configuration); $consumer = new PlancakeOpenIdConsumer(PlancakeOpenIdConsumer::PROVIDER_GOOGLE, 'http://www.plancake.com/openIdEndpoints/googleReceiveLogin.php', PlancakeOpenIdConsumer::MODE_LOGIN); $consumer->receive($data); $email = $data['http://axschema.org/contact/email'][0]; if (PcUserPeer::emailExist($email)) { $userToLogin = PcUserPeer::retrieveByEmailAddress($email); CustomAuth::login($context->getUser(), $userToLogin, false, false); if (PcUtils::isMobileBrowser()) { $redirectUrl = 'https://' . sfConfig::get('app_site_url') . "/account.php/mobile"; } else { $redirectUrl = 'http://' . sfConfig::get('app_site_url') . "/account.php"; } } else { $encodedEmail = urlencode($email); $redirectUrl = 'http://' . sfConfig::get('app_site_url') . "/openIdWrongLogin?input_email={$encodedEmail}"; } header("Location: {$redirectUrl}");