public function doSave($con = null)
 {
     if ($this->isNew) {
         $user = new sfGuardUser();
         $user->setUsername($this->getValue('username'));
         $user->setPassword($this->getValue('password'));
         $user->setEmailAddress($this->getValue('email'));
         $user->addGroupByName(sfConfig::get('app_user_default_group'));
         // They must confirm their account first
         $user->setIsActive(false);
         $user->save();
         $this->getObject()->setUserId($user->getId());
     }
     return parent::doSave($con);
 }
 public function executeIdentification(sfWebRequest $request)
 {
     if (!$this->getUser()->isAuthenticated()) {
         $this->formInscription = new InscriptionForm();
         $class = sfConfig::get('app_sf_guard_plugin_signin_form', 'sfGuardFormSignin');
         $this->form = new $class();
         if ($request->ismethod('post')) {
             if ($request->getParameter('send') == "signin") {
                 $this->form->bind($request->getParameter('signin'));
                 if ($this->form->isValid()) {
                     $values = $this->form->getValues();
                     $this->getUser()->signin($values['user'], array_key_exists('remember', $values) ? $values['remember'] : false);
                     if ($this->getUser()->getAttribute('montantLocation')) {
                         $paypal = new PayPal();
                         $ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture');
                         print_r($ret);
                     } else {
                         $this->redirect('espace_membre_profil');
                     }
                 }
             } else {
                 if ($request->getParameter('send') == "signup") {
                     $this->formInscription->bind($request->getParameter('signup'));
                     if ($this->formInscription->isValid()) {
                         $values = $this->formInscription->getValues();
                         //print_r($values);
                         //exit;
                         $user = new sfGuardUser();
                         $user->setEmailAddress($values['email_address']);
                         $user->setUsername($values['email_address']);
                         $user->setLastName($values['nom']);
                         $user->setFirstName($values['prenom']);
                         $user->setPassword($values['password1']);
                         $user->setIsActive(1);
                         $user->getProfile()->setAdresse($values['adresse']);
                         $user->getProfile()->setCodepostal($values['codepostal']);
                         $user->getProfile()->setVille($values['ville']);
                         $user->getProfile()->setFixe($values['fixe']);
                         $user->getProfile()->setMobile($values['mobile']);
                         $user->getProfile()->setDateNaissance($values['date_naissance']);
                         $user->getProfile()->setNumeroPermis($values['numero_permis']);
                         $user->getProfile()->setVilleDelivrance($values['ville_permis']);
                         $user->getProfile()->setPaysDelivrance($values['pays_permis']);
                         $user->getProfile()->setDateDelivrance($values['date_delivrance_permis']);
                         $user->getProfile()->setIsActivated(1);
                         $user->addGroupByName("client");
                         $user->save();
                         $this->getUser()->setAttribute('email_address', $values['email_address']);
                         $message = $this->getMailer()->compose(sfConfig::get('app_mail_saidi'), $values['email_address'], '[Mobilyrent] - Inscription Mobilyrent location de voiture', '[Mobilyrent] - Inscription Mobilyrent location de voiture');
                         $this->getMailer()->send($message);
                         //echo $this->getUser()->getAttribute('montantLocation');exit;
                         if ($this->getUser()->getAttribute('montantLocation')) {
                             $paypal = new PayPal();
                             $ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture');
                             print_r($ret);
                         }
                         //$this->getUser()->setFlash('notice', sprintf('Inscription terminée.<br/>Un email vous a été envoyé. Connectez vous et continuer votre reservation.'));
                     }
                 }
             }
         }
     } else {
         $paypal = new PayPal();
         $ret = $paypal->doExpressCheckout($this->getUser()->getAttribute('montantLocation'), 'Location de la voiture');
         print_r($ret);
     }
 }
示例#3
0
 public function executeInvite($request)
 {
     $this->user_invite_form = new UserInviteForm();
     if ($request->isMethod('post')) {
         $userParams = $request->getParameter('user');
         $this->user_invite_form->bind($userParams);
         if ($this->user_invite_form->isValid()) {
             $db = Doctrine_Manager::connection();
             try {
                 $db->beginTransaction();
                 //create user
                 $user = new sfGuardUser();
                 $user->username = $userParams['email'];
                 $user->algorithm = 'sha1';
                 $user->setPassword('pending');
                 $user->is_active = false;
                 $user->addGroupByName($userParams['group']);
                 $user->save();
                 //create user profile
                 $profile = new sfGuardUserProfile();
                 $profile->user_id = $user->id;
                 $profile->name_first = $userParams['name_first'];
                 $profile->name_last = $userParams['name_last'];
                 $profile->email = $userParams['email'];
                 $profile->is_visible = false;
                 $profile->invitation_code = substr(sha1($profile->getEmail() . time()), 0, 10);
                 $profile->save();
                 //send welcome email
                 $mailBody = $this->getPartial($userParams['template'], array('profile' => $profile));
                 $mailer = new Swift(new Swift_Connection_NativeMail());
                 $message = new Swift_Message("You're invited to become a LittleSis analyst!", $mailBody, 'text/plain');
                 $address = new Swift_Address(sfConfig::get('app_mail_invite_sender_address'), sfConfig::get('app_mail_invite_sender_name'));
                 $mailer->send($message, $profile->email, $address);
                 $mailer->disconnect();
                 //all's well, commit transaction
                 $db->commit();
             } catch (Exception $e) {
                 $db->rollback();
                 throw $e;
             }
             $this->redirect('user/list');
         }
         //gather errors
         $this->errors = $this->user_invite_form->getErrorSchema()->getErrors();
     }
 }
 /**
  * Save client profile content
  * @param web request $request
  */
 public function executeUpdate($request)
 {
     /**login user infomation**/
     $sf_user = $this->getUser();
     $sf_guard_user = $sf_user->getGuardUser();
     $sf_user_profile = $sf_guard_user->getProfile();
     $sf_user_id = $sf_guard_user->getId();
     $branch_id = $sf_user->getUserBranch()->getId();
     $company_id = $sf_user->getUserCompany()->getId();
     $this->marketing_options = '';
     $this->cop_record_updated = '';
     $client_user_id = NULL;
     //    if($sf_ser->isBranchOwner($sf_user_id) && $sf_user->hasAttribute('branch_id'))
     if ($sf_user->isBranchOwner($sf_user_id)) {
         //        $client_user_id = $this->getRequestParameter('id');
         $client_profile_id = $this->getRequestParameter('id');
         if (!empty($client_profile_id)) {
             $client_user = ProfilePeer::retrieveByPK($client_profile_id);
             $client_user_id = $client_user->getUserId();
         }
         /*
          * available in case branch owner is handling more than branch
          * if the client is new that it need branch_id from url
          */
         if ($this->getRequestParameter('branch_id')) {
             $branch_id = $this->getRequestParameter('branch_id');
         } elseif ($client_user_id) {
             $client_branch = new Criteria();
             $client_branch->add(BranchUsersPeer::USER_ID, $client_user_id);
             $client_branch->setDistinct();
             $branchId = BranchUsersPeer::doSelect($client_branch);
             $branch_id = $branchId[0]->getBranchId();
         }
         $company_id = BranchPeer::getCompanyId($branch_id);
     }
     $parent = $request->getParameter('opportunity_parent_exist', 0);
     $this->logindetails = array();
     $this->logindetails['username'] = '';
     $this->logindetails['password'] = '';
     $this->logindetails['confirm_password'] = '';
     $this->logindetails['budget'] = '';
     $this->logindetails['expected_close_date'] = '';
     $this->getSignedContractDate = '';
     $this->another_contact_list = '';
     $this->another_contact_form = new anotherContactPersonForm();
     $this->client_leads = ClientLeadPeer::getClientLeadsList($branch_id);
     $login_details = $request->getParameter('logindetail');
     $branch_service = new BranchService($branch_id, $sf_user_id);
     $this->marketing_options = $branch_service->getMarketingOptionList();
     $this->is_showlead = $branch_service->isShowLead();
     $this->sub_opportunity_exist = null;
     if ($login_details) {
         $this->logindetails = $login_details;
         if ($this->logindetails['expected_close_date']) {
             $this->logindetails['expected_close_date'] = date('Y-m-d', strtotime($this->logindetails['expected_close_date'])) . ' ' . date('H:i:s');
         }
     }
     $this->getSignedContractDate = $this->logindetails['signed_contract_date'];
     /*
      * get current branch branch office staff list (any one of these should be the sales person)
      */
     $tempsale = array();
     $tempsale[$sf_user_id] = $sf_user->getProfile()->getFullname();
     $sales = ProfilePeer::getBranchUsers($branch_id, sfGuardGroupPeer::BRANCH_OFFICE_STAFF);
     foreach ($sales as $salesid) {
         $tempsale[$salesid->getUserId()] = $salesid->getFullname();
     }
     $this->sales_persons = $tempsale;
     $this->default_sales = $sf_user_id;
     $client_profile = '';
     $this->client_profile = '';
     $client_id = $request->getParameter('id');
     if ($client_id) {
         $client_profile = ProfilePeer::retrieveByPK($client_id);
         $client_user_id = $client_profile->getUserId();
         $this->client_ranks = clientRankPeer::getClientOpportunityList($branch_id);
         $this->default_rank = 0;
         $this->default_sub_rank = null;
         $this->default_lead = 0;
         if (!empty($client_profile)) {
             $this->default_rank = $client_profile->getRank() ? $client_profile->getRank() : 0;
             $this->default_sub_rank = $client_profile->getSubOpportunity() ? $client_profile->getSubOpportunity() : null;
         }
         $this->client_profile = $client_profile;
         if ($client_profile->getOther2() == '') {
             $ref = $this->genRandomString();
             $client_profile->setOther2($ref);
         }
         $this->form = new ClientQuickForm($client_profile);
         $client_login = sfGuardUserPeer::retrieveByPK($client_user_id);
         $this->client_login = $client_login;
         $c = new Criteria();
         $c->add(anotherContactPersonPeer::USER_ID, $client_user_id, Criteria::EQUAL);
         $this->another_contact_list = anotherContactPersonPeer::doSelect($c);
     } else {
         $ref = $this->genRandomString();
         $this->form = new ClientQuickForm();
         $this->form->setDefault('other2', $ref);
         $this->client_ranks = clientRankPeer::getClientOpportunityList($branch_id);
         $this->default_rank = 0;
         $this->default_sub_rank = null;
         $this->default_lead = 0;
         if (!empty($client_profile)) {
             $this->default_rank = $client_profile->getSubOpportunity() ? $client_profile->getSubOpportunity() : $client_profile->getRank();
             $this->default_lead = $client_profile->getLead();
         }
     }
     /*
      * save data to database
      */
     if ($request->isMethod('post')) {
         $form_data = $request->getParameter('profile');
         $prefered = null;
         if ($request->getParameter('preferedPhone')) {
             $prefered = $request->getParameter('preferedPhone');
         } elseif ($request->getParameter('preferedAfterHourPhone')) {
             $prefered = $request->getParameter('preferedAfterHourPhone');
         } elseif ($request->getParameter('preferedMobile')) {
             $prefered = $request->getParameter('preferedMobile');
         }
         $form_data['updated_at'] = date('Y-m-d H:i:s');
         $form_data['updated_by_id'] = $sf_user_id;
         $form_data['prefered_contact'] = $prefered;
         $form_data['user_id'] = $client_user_id;
         $sales_id = $form_data['sales_id'];
         if (!$sales_id) {
             $form_data['sales_id'] = $sf_user_id;
         } else {
             $form_data['sales_id'] = $sales_id;
         }
         if ($parent) {
             $sub_opportunity = $form_data['rank'];
             $sub_opportunities = SubOpportunityPeer::retrieveByPK($sub_opportunity);
             $opportunities = clientRankPeer::retrieveByPK($sub_opportunities->getOpportunityId());
             $form_data['rank'] = $opportunities->getRankId();
             $form_data['sub_opportunity'] = $sub_opportunity;
             if ($opportunities->getRankId() == 7) {
                 $form_data['lead'] = ClientLeadPeer::getBranchLostId($branch_id);
             }
         } else {
             $form_data['sub_opportunity'] = null;
         }
         $client_rank = $form_data['rank'] - 1;
         $this->project = null;
         if ($client_rank == 5) {
             $c = new Criteria();
             $c->add(pmProjectsPeer::CLIENT_ID, $client_user_id);
             $c->addDescendingOrderByColumn(pmProjectsPeer::CREATED_AT);
             $this->project = pmProjectsPeer::doSelectOne($c);
         }
         $this->form->bind($form_data);
         if ($this->form->isValid()) {
             $status = sfConfig::get('mod_client_opportunity_accountstatus');
             $form_data['account_status'] = accountStatusPeer::getStatusId($status[$client_rank]) + 1;
             if ($this->form->isNew()) {
                 $form_data['created_by_id'] = $sf_user_id;
                 $form_data['created_at'] = date('Y-m-d H:i:s');
                 $form_data['updated_at'] = date('Y-m-d H:i:s');
                 $form_data['updated_by_id'] = $sf_user_id;
                 /*
                  *  save client instance into sfguard
                  */
                 $sf_object = new sfGuardUser();
                 $tools_obj = new myTools();
                 /*
                  * login infomation
                  */
                 if (!array_key_exists('username', $login_details) || !$login_details['username']) {
                     $client_username = $tools_obj->RandomUsernameGenerator();
                     $sf_object->setUsername($client_username);
                 } else {
                     $sf_object->setUsername($login_details['username']);
                 }
                 if (!array_key_exists('password', $login_details) || !$login_details['password']) {
                     $sf_object->setPassword($tools_obj->randomPasswordGenerator());
                 } else {
                     $sf_object->setPassword($login_details['username']);
                 }
                 $sf_object->save();
                 $sf_object->addGroupByName('client');
                 $new_user_id = $sf_object->getId();
                 $form_data['user_id'] = $new_user_id;
                 $enquiry_details = new Inquiry();
                 $enquiry_details->setUserId($new_user_id);
                 if ($login_details['budget'] != '') {
                     $enquiry_details->setBudget($login_details['budget']);
                 }
                 if ($login_details['expected_close_date'] != '') {
                     $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime($login_details['expected_close_date'])));
                 } elseif ($login_details['expected_close_date'] == '') {
                     $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime(date('Y-m-01') . ' +6 month')));
                 }
                 $enquiry_details->save();
                 /*
                  *  save instance into branch users
                  */
                 $branch_object = new BranchUsers();
                 $branch_object->addBranchUser($new_user_id, $branch_id);
                 // set intance into company users
                 $company_object = new CompanyUsers();
                 $company_object->addCompanyUser($new_user_id, $company_id);
             } else {
                 $enquiry_id = InquiryPeer::getEnquiryId($client_user_id);
                 $enquiry_details = InquiryPeer::retrieveByPK($enquiry_id);
                 if ($enquiry_details) {
                     $enquiry_details->setBudget($login_details['budget']);
                     $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime($login_details['expected_close_date'])));
                     $enquiry_details->save();
                 } else {
                     $enquiry_details = new Inquiry();
                     $enquiry_details->setUserId($client_login->getId());
                     if ($login_details['budget'] != '') {
                         $enquiry_details->setBudget($login_details['budget']);
                     }
                     if ($login_details['expected_close_date'] != '') {
                         $enquiry_details->setExpectedCloseDate(date('Y-m-d', strtotime($login_details['expected_close_date'])));
                     }
                     $enquiry_details->save();
                 }
                 if ($client_login) {
                     $client_login->setUsername($this->logindetails['username']);
                     if ($this->logindetails['password'] != '') {
                         $client_login->setPassword($this->logindetails['password']);
                     }
                     $client_login->save();
                     $new_user_id = $client_login->getId();
                 }
             }
             if ($login_details['signed_contract_value'] != '') {
                 $conn = Propel::getConnection();
                 //                    need update only one record in the furture
                 $cor = new Criteria();
                 $cor->add(pmProjectsPeer::CLIENT_ID, $client_user_id);
                 $cor->addDescendingOrderByColumn(pmProjectsPeer::CREATED_AT);
                 $cor_new = new Criteria();
                 $cor_new->add(pmProjectsPeer::ACTUAL_BUILD_COST, $login_details['signed_contract_value']);
                 $cor_new->add(pmProjectsPeer::UPDATED_BY_ID, $sf_user_id);
                 $cor_new->add(pmProjectsPeer::UPDATED_AT, date('Y-m-d H:i:s'));
                 BasePeer::doUpdate($cor, $cor_new, $conn);
             }
             /*
              * save the form to profile
              */
             $profile = $this->form->save();
             $profile->setUserId($new_user_id ? $new_user_id : $client_user_id);
             $profile->save();
             $old_opportunity_id = 0;
             $old_sub_opportunity_id = 0;
             $old_opportunity_id = $this->default_rank;
             $old_sub_opportunity_id = $this->default_sub_rank;
             $new_opp_record = false;
             $c_opp_record = new Criteria();
             $c_opp_record->add(ClientOpportunityRecordPeer::USER_ID, $client_user_id);
             if ($old_sub_opportunity_id) {
                 $c_opp_record->add(ClientOpportunityRecordPeer::SUB_OPPORTUNITY_ID, $old_sub_opportunity_id, Criteria::IN);
                 $opportunity_records = ClientOpportunityRecordPeer::doSelect($c_opp_record);
             } elseif ($old_opportunity_id) {
                 $c_opp_record->add(ClientOpportunityRecordPeer::OPPORTUNITY_ID, $old_opportunity_id, Criteria::IN);
                 $opportunity_records = ClientOpportunityRecordPeer::doSelect($c_opp_record);
             } else {
                 $opportunity_records = Null;
             }
             if (empty($opportunity_records)) {
                 $new_opp_record = true;
             }
             $new_opportunity_id = $profile->getRank();
             $new_sub_opportunity_id = $profile->getSubOpportunity();
             if ($new_opp_record) {
                 $client_opportunity_record = new ClientOpportunityRecord();
                 $client_opportunity_record->setOpportunityId($new_opportunity_id);
                 $client_opportunity_record->setSubOpportunityId($new_sub_opportunity_id);
                 $client_opportunity_record->setUserId($profile->getUserId());
                 $client_opportunity_record->setCreatedById($sf_user_id);
                 $client_opportunity_record->setUpdatedById($sf_user_id);
                 $client_opportunity_record->save();
             } else {
                 $conn = Propel::getConnection();
                 $client_opportunity_record_criteria = new Criteria();
                 $client_opportunity_record_criteria->add(ClientOpportunityRecordPeer::USER_ID, $profile->getUserId());
                 $client_opportunity_record_criteria->add(ClientOpportunityRecordPeer::OPPORTUNITY_ID, $new_opportunity_id);
                 $client_opportunity_record_criteria->add(ClientOpportunityRecordPeer::SUB_OPPORTUNITY_ID, $new_sub_opportunity_id);
                 $cor_new = new Criteria();
                 if ($new_opportunity_id == 6) {
                     if (!empty($this->getSignedContractDate)) {
                         $signed_updated_date = date('Y-m-d', strtotime($this->getSignedContractDate)) . ' ' . date('H:i:s');
                         $cor_new->add(ClientOpportunityRecordPeer::UPDATED_AT, $signed_updated_date);
                     }
                 } else {
                     $cor_new->add(ClientOpportunityRecordPeer::UPDATED_AT, date('Y-m-d H:i:s'));
                 }
                 $cor_new->add(ClientOpportunityRecordPeer::UPDATED_BY_ID, $sf_user_id);
                 BasePeer::doUpdate($client_opportunity_record_criteria, $cor_new, $conn);
             }
             if ($old_opportunity_id != $new_opportunity_id || $old_sub_opportunity_id != $new_sub_opportunity_id) {
                 $client_opportunity_log = new ClientOpportunityLog();
                 $client_opportunity_log->setUserId($profile->getUserId());
                 $client_opportunity_log->setOpportunityId($new_opportunity_id);
                 $client_opportunity_log->setSubOpportunityId($new_sub_opportunity_id);
                 $client_opportunity_log->setCreatedById($sf_user_id);
                 $client_opportunity_log->save();
             }
             /*
              *  delete record from another contact from current client
              */
             $c = new Criteria();
             $c->add(anotherContactPersonPeer::USER_ID, $profile->getUserId());
             $another = anotherContactPersonPeer::doDelete($c);
             // add record from client
             $another_details = $request->getParameter('contact_person');
             $no_of_fields = 5;
             $count_person_list = count($another_details) / $no_of_fields;
             $j = $no_of_fields;
             for ($i = 0; $i < $count_person_list - 1; $i++) {
                 $fname = $another_details[$j]['fname'];
                 $lname = $another_details[$j + 1]['lname'];
                 if ($fname != '' || $lname != '') {
                     $an_details = new anotherContactPerson();
                     $an_details->setUserId($profile->getUserId());
                     $an_details->setFname($another_details[$j++]['fname']);
                     $an_details->setLname($another_details[$j++]['lname']);
                     $an_details->setPhone($another_details[$j++]['phone']);
                     $an_details->setEmail($another_details[$j++]['email']);
                     $an_details->setMobile($another_details[$j++]['mobile']);
                     $an_details->save();
                 } else {
                     $j = $j + $no_of_fields;
                 }
             }
             if (!$request->getParameter('rdindex')) {
                 $profile_id = $profile->getId();
                 $profile_user_id = $profile->getUserId();
                 // save client details in the activity logs table
                 $modification_message = $this->form->isNew() ? 'Create Profile' : 'Update Profile';
                 $this->saveHistory($modification_message, $profile_user_id);
                 if ($this->form->isNew()) {
                     $reminder = sfConfig::get('mod_client_messages_msg4');
                     $sf_user->setFlash('notice', $reminder);
                     $this->redirect('client/show?id=' . $profile_id);
                 }
                 $client_info = sfConfig::get('mod_client_messages_msg2');
                 $sf_user->setFlash('notice', $client_info);
                 $this->redirect('client/show?id=' . $profile_id);
             }
             $profile_id = $profile->getId();
             $this->redirect('inquiry/edit?id=' . $profile_id);
         }
         if (isset($profile)) {
             $this->sub_opportunity_exist = $profile->getSubOpportunity() ? 1 : 0;
         }
         $this->setTemplate('edit');
     }
 }
$activeUser->first_name = 'John';
$activeUser->last_name = 'Doe';
$activeUser->email_address = '*****@*****.**';
$activeUser->username = '******';
$activeUser->password = '******';
$activeUser->is_active = true;
$activeUser->save();
// ->__toString()
$t->diag('output functions');
$t->is((string) $activeUser, 'John Doe (active_user)', '->__toString() returns the full name and the username');
$t->is($activeUser->getName(), 'John Doe', '->getName() returns the full name of the user');
// group managment
$t->diag('group managment');
$t->is($activeUser->getGroupNames(), array(), '->getGroupNames() return empty array if no group is set');
try {
    $activeUser->addGroupByName('test-group');
    $t->fail('->addGroupByName() does throw an exception if group not exist');
} catch (Exception $e) {
    $t->pass('->addGroupByName() does throw an exception if group not exist');
}
$group = new sfGuardGroup();
$group->name = 'test-group';
$group->save();
$t->is($activeUser->hasGroup('test-group'), false, '->hasGroup() return false if user hasn\'t this group');
try {
    $activeUser->addGroupByName('test-group');
    $t->pass('->addGroupByName() does not throw an exception if group exist');
} catch (Exception $e) {
    $t->diag($e->getMessage());
    $t->fail('->addGroupByName() does not throw an exception if group exist');
}
示例#6
0
 public function ajouterUtilisateur($values)
 {
     $user = new sfGuardUser();
     $user->setEmailAddress($values['email_address']);
     $user->setUsername($values['email_address']);
     $user->setLastName($values['nom']);
     $user->setFirstName($values['prenom']);
     $user->setPassword($values['password1']);
     $user->setIsActive(1);
     $user->getProfile()->setAdresse($values['adresse']);
     $user->getProfile()->setCodepostal($values['codepostal']);
     $user->getProfile()->setVille($values['ville']);
     $user->getProfile()->setFixe($values['fixe']);
     $user->getProfile()->setMobile($values['mobile']);
     $user->getProfile()->setDateNaissance($values['date_naissance']);
     $user->getProfile()->setNumeroPermis($values['numero_permis']);
     $user->getProfile()->setVilleDelivrance($values['ville_permis']);
     $user->getProfile()->setPaysDelivrance($values['pays_permis']);
     $user->getProfile()->setDateDelivrance($values['date_delivrance_permis']);
     $user->getProfile()->setIsActivated(1);
     $user->addGroupByName("client");
     $user->save();
     $this->getUser()->setAttribute('email_address', $values['email_address']);
     return $user;
 }