示例#1
0
 public function logoutAction()
 {
     $this->_helper->layout->disableLayout();
     $this->_helper->viewRenderer->setNoRender();
     $service = new Service_User();
     $service->logout();
     $this->_helper->redirector('index', 'index');
 }
示例#2
0
 public function authenticate()
 {
     $user = Doctrine_Core::getTable('Model_User')->findOneBy('username', $this->_username);
     //Check If Account Was Found
     if (!$user) {
         $this->_resultInfo['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
         $this->_resultInfo['messages'][] = 'No account with that username could be located';
         return $this->_createAuthResult();
     }
     //Check If Account Has Been Verified
     if (!$user->verified) {
         $this->_resultInfo['code'] = Zend_Auth_Result::FAILURE;
         $this->_resultInfo['messages'][] = 'This account has not been verified. Please check your e-mail for instructions on completing this process';
         return $this->_createAuthResult();
     }
     //Check If Account Is Enabled
     if (!$user->enabled) {
         $this->_resultInfo['code'] = Zend_Auth_Result::FAILURE;
         $this->_resultInfo['messages'][] = "Account has been disabled";
         return $this->_createAuthResult();
     }
     //Compare Password
     $bcrypt = new Cryptography_PasswordService();
     /*if($user->password =! ($test = $bcrypt->verify($this->_password, $user->password))) {
           $this->_resultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
           $this->_resultInfo['identity'] = $this->_username;
           $this->_resultInfo['messages'][] = $test."    ".$user->password;
           return $this->_createAuthResult();
       }*/
     if (!$bcrypt->verify($this->_password, $user->password)) {
         $this->_resultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
         $this->_resultInfo['identity'] = $this->_username;
         $this->_resultInfo['messages'][] = "Login Failed. Password Incorrect.";
         $userService = new Service_User();
         if ($userService->registerFailure($user->id) > Zend_Registry::get('maxAccessAttempts')) {
             $userService->disableAccount($user->id);
             $this->_resultInfo['messages'][] = "This account has been locked due to multiple failed access attempts";
         }
         return $this->_createAuthResult();
     }
     //Set Login Info
     $userService = new Service_User();
     if ($profile = $userService->getUserProfile($user->id)) {
         $user->mapValue('profileid', $profile->id);
         $user->mapValue('storyNotificationPeriod', $profile->story_notification_period);
         $user->mapValue('locationid', $profile->location);
         $user->mapValue('cityid', $profile->Location->cityid);
         $user->mapValue('stateprovid', $profile->Location->stateprovid);
         $user->mapValue('countryid', $profile->Location->countryid);
     }
     $user['password'] = "";
     $this->_resultInfo['identity'] = $user;
     $this->_resultInfo['code'] = Zend_Auth_Result::SUCCESS;
     $this->_resultInfo['messages'][] = "Login was successful";
     $userService->registerLogin($user->id);
     return $this->_createAuthResult();
 }
示例#3
0
 public function authenticate()
 {
     $user = $this->_xpdo->newObject($this->_className, array($this->_identityVar => $this->_identity));
     if (!is_object($user)) {
         $this->_resultInfo['code'] = Zend_Auth_Result::FAILURE_IDENTITY_NOT_FOUND;
         $this->_resultInfo['messages'][] = 'No account with that username could be located';
         return $this->_createAuthResult();
     }
     //Check If Account Is Enabled
     if ($user->status) {
         //Check Credentials
         $hashing = new Cryptography_HashingService();
         if ($hashing->Verify($this->_credentials, $user->password)) {
             $userService = new Service_User();
             if ($profile = $userService->getUserProfile($user->id)) {
                 $user->profile = $profile;
             } else {
                 $this->_resultInfo['messages'][] = "Could not load User Profile";
             }
             $this->_resultInfo['identity'] = $user;
             $this->_resultInfo['code'] = Zend_Auth_Result::SUCCESS;
             $this->_resultInfo['messages'][] = "Login was successful";
             return $this->_createAuthResult();
         } else {
             $this->_resultInfo['code'] = Zend_Auth_Result::FAILURE_CREDENTIAL_INVALID;
             $this->_resultInfo['identity'] = $this->_identity;
             $this->_resultInfo['messages'][] = "The password supplied is not correct";
             $userService = new Service_User();
             if ($userService->registerFailure($user->id) > Zend_Registry::get('maxAccessAttempts')) {
                 $userService->disableAccount($user->id);
                 $this->_resultInfo['messages'][] = "The account has been locked due to multiple failed access attempts";
             }
             return $this->_createAuthResult();
         }
     } else {
         $this->_resultInfo['code'] = Zend_Auth_Result::FAILURE;
         $this->_resultInfo['messages'][] = "That account is not currently enabled. If this is a new account, please check for your confirmation e-mail";
         return $this->_createAuthResult();
     }
 }
 public function searchAction()
 {
     if ($this->getRequest()->isGet()) {
         if ($terms = $this->getRequest()->getParam('searchTerms', FALSE)) {
             $userService = new Service_User();
             if (is_array($results = $userService->searchUsers($terms))) {
                 $this->_helper->layout->setLayout('topmenu');
                 for ($i = 0; $i < count($results); $i++) {
                     if ($this->_user->profileid == $results[$i]['id']) {
                         unset($results[$i]);
                         continue;
                     }
                     $friended = false;
                     if (count($results[$i]['Friends'])) {
                         foreach ($results[$i]['Friends'] as $friend) {
                             if ($this->_user->id == $friend['friend']) {
                                 $friended = true;
                                 break;
                             }
                         }
                     }
                     $results[$i]['friend'] = $friended;
                     $results[$i]['connections'] = count($results[$i]['Friends']);
                     if (!$friended) {
                         $request = false;
                         if (count($results[$i]['OutgoingFriendRequests'])) {
                             foreach ($results[$i]['OutgoingFriendRequests'] as $outgoing) {
                                 if ($this->_user->id == $outgoing['requestee']) {
                                     $request = true;
                                     $results[$i]['requestid'] = $outgoing['id'];
                                     break;
                                 }
                             }
                         }
                         $results[$i]['incomingRequest'] = $request;
                         if (!$request) {
                             $requested = false;
                             if (count($results[$i]['IncomingFriendRequests'])) {
                                 foreach ($results[$i]['IncomingFriendRequests'] as $incoming) {
                                     if ($this->_user->id == $incoming['requestor']) {
                                         $requested = true;
                                         $results[$i]['requestid'] = $incoming['id'];
                                         break;
                                     }
                                 }
                             }
                             $results[$i]['outgoingRequest'] = $requested;
                         }
                     }
                 }
                 $result['root'] = $results;
                 $this->view->searchTerms = $terms;
                 $this->view->resultTotal = count($results);
                 $this->view->searchNoPerPage = 5;
                 $this->view->users = $result;
                 return $this->render('searchresults');
             }
         }
     }
 }