/** * Sends new password to the requester * Can retrieve via Username or MemberId * @param sfWebRequest $request */ public function executeSendPassword(sfWebRequest $request) { if ($request->isMethod('post')) { $request->checkCSRFProtection(); $username = $request->getParameter('username'); $member_id = $request->getParameter('member_id'); if (strlen($username) > 0 || strlen($member_id) > 0) { $person = null; if ($member_id) { $member = MemberPeer::retrieveByPK($member_id); if ($member instanceof Member) { $person = $member->getPerson(); } } elseif ($username) { $person = PersonPeer::getByUsername($username); } if ($person instanceof Person) { # create token for password request $pr = new PasswordRequest(); $pr->setPerson($person); $pr->setEmail($person->getEmail()); $pr->save(); if ($person->getEmail()) { # send email via component $this->getComponent('mail', 'sendPassword', array('person' => $person, 'token' => $pr->getToken())); $this->getUser()->setFlash('success', 'Your password request has been successfully sent to your email!'); } else { $this->getUser()->setFlash('success', 'This user doesn\'t have proper email address!'); } # redirect to login $this->redirect('secure/login'); } $this->error_msg = 'Sorry! We haven\'t found any matching record!'; } else { $this->error_msg = 'Please type your username OR member id!'; } } $this->executeForgotPassword($request); $this->setTemplate('forgotPassword'); }
public function executeUpdatePassword(sfWebRequest $request) { if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Member', 'Coordinator', 'Volunteer'), false)) { $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer()); $this->redirect('dashboard/index'); } $username = $this->getUser()->getUsername(); $this->person = PersonPeer::getByUsername($username); if ($request->isMethod('post')) { if ($old_pass = $request->getParameter('old_pass')) { if ($this->person->isPassword($old_pass)) { $required_len = sfConfig::get('app_password_minimum_length'); $new_pass = $request->getParameter('new_pass'); $confirm_pass = $request->getParameter('confirm_pass'); if (strlen($new_pass) >= $required_len && strlen($confirm_pass) >= $required_len) { if ($new_pass == $confirm_pass) { $this->person->setPassword($confirm_pass); $this->person->save(); $this->getUser()->setFlash('success', 'Your password has been successfully changed!'); $this->redirect('account/index'); } else { $this->error_msg = 'New passwords doesn\'t match!'; } } else { $this->error_msg = 'Your password must be at least ' . $required_len . ' characters!'; } } else { $this->error_msg = 'Your old password is not right!'; } } else { $this->error_msg = 'Please enter your old password!'; } } }
public function executeUpdatePassword(sfWebRequest $request) { if ($this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) { $username = $this->getUser()->getUsername(); $this->person = PersonPeer::getByUsername($username); $this->chperson = PersonPeer::retrieveByPK($request->getParameter('id')); $this->personId = $request->getParameter('id'); if ($request->isMethod('post')) { if ($old_pass = $request->getParameter('old_pass')) { if ($this->person->isPassword($old_pass)) { $required_len = sfConfig::get('app_password_minimum_length'); $new_pass = $request->getParameter('new_pass'); $confirm_pass = $request->getParameter('confirm_pass'); if (strlen($new_pass) >= $required_len && strlen($confirm_pass) >= $required_len) { if ($new_pass == $confirm_pass) { $this->chperson->setPassword($confirm_pass); $this->chperson->save(); $this->getUser()->setFlash('success', 'Your password has been successfully changed!'); $this->redirect('person/view?id=' . $this->chperson->getId()); } else { $this->error_msg = 'New passwords doesn\'t match!'; } } else { $this->error_msg = 'Your password must be at least ' . $required_len . ' characters!'; } } else { $this->error_msg = 'Your old password is not right!'; } } else { $this->error_msg = 'Please enter your old password!'; } } } else { $this->getUser()->setFlash('warning', 'alkdjfdksjfladjkf'); } }