示例#1
0
 public function executeNewPassword(sfWebRequest $request)
 {
     if ($request->isMethod('post')) {
         $request->checkCSRFProtection();
         $member_Extar_id = $request->getParameter('member_id2');
         $username = $request->getParameter('usernamee');
         $password = $request->getParameter('passwordd');
         $confirm = $request->getParameter('corfirm_passwordd');
         $lastname = $request->getParameter('lastname');
         $zipcode = $request->getParameter('zipcode');
         $password_len = strlen($password);
         $required_len = sfConfig::get('app_password_minimum_length');
         # validate form
         if (strlen($username) > 0 && $password_len > 0 && strlen($confirm) > 0) {
             if ($password_len < $required_len) {
                 $this->error_msg = 'Password must be at least ' . $required_len . ' characters';
             } else {
                 if ($password == $confirm) {
                     $member = MemberPeer::getByExternalId($member_Extar_id);
                     if ($member) {
                         $person = $member->getPerson();
                         if ($person instanceof Person) {
                             if ($person->getUsername() == null && $person->getUsername() == null) {
                                 $person->setUsername($username);
                                 if ($password == $confirm) {
                                     $person->setPassword($password);
                                 }
                                 $person->save();
                                 $this->signIn($person, $request);
                                 $this->getUser()->setFlash('success', 'Your password has been successfully created!');
                                 $this->redirect('/dashboard/index');
                             } elseif ($person->getLastName() == $lastname && $person->getZipcode() == $zipcode) {
                                 if ($person->getUsername() == $username) {
                                     # set new password
                                     $person->setPassword($password);
                                     $person->save();
                                     $this->signIn($person, $request);
                                     $this->getUser()->setFlash('success', 'Your password has been successfully changed!');
                                     $this->redirect('@homepage');
                                 } else {
                                     $this->error_msg = 'You typed incorrect username!';
                                 }
                             } elseif ($person->getUsername() != null && $person->getUsername() != null) {
                                 $this->signIn($person, $request);
                                 $this->getUser()->setFlash('success', 'Person has already username and password! Please use following form to login.If you forget password can renew it!');
                                 $this->redirect('@login');
                             } else {
                                 # invalid hidden field info
                                 $this->redirect('secure/retrievePassword');
                             }
                         } else {
                             # invalid hidden field info
                             $this->redirect('secure/retrievePassword');
                         }
                     } else {
                         # invalid hidden field info
                         $this->redirect('secure/retrievePassword');
                     }
                 } else {
                     $this->error_msg = 'Passwords don\'t match!';
                 }
             }
         } else {
             $this->error_msg = 'Please fill all fields!';
         }
     }
     $this->executeCreatePassword($request);
     $this->setTemplate('createPassword');
 }