Exemplo n.º 1
0
 /**
  * Generate a temp password by answering to the pre-determined question
  *
  * @return void|Object (void : success, Object : fail)
  */
 function procMemberFindAccountByQuestion()
 {
     $oMemberModel = getModel('member');
     $config = $oMemberModel->getMemberConfig();
     if ($config->enable_find_account_question != 'Y') {
         return new Object(-1, 'msg_question_not_allowed');
     }
     $email_address = Context::get('email_address');
     $user_id = Context::get('user_id');
     $find_account_question = trim(Context::get('find_account_question'));
     $find_account_answer = trim(Context::get('find_account_answer'));
     if ($config->identifier == 'user_id' && !$user_id || !$email_address || !$find_account_question || !$find_account_answer) {
         return new Object(-1, 'msg_invalid_request');
     }
     $oModuleModel = getModel('module');
     // Check if a member having the same email address exists
     $member_srl = $oMemberModel->getMemberSrlByEmailAddress($email_address);
     if (!$member_srl) {
         return new Object(-1, 'msg_email_not_exists');
     }
     // Get information of the member
     $columnList = array('member_srl', 'find_account_question', 'find_account_answer');
     $member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
     // Display a message if no answer is entered
     if (!$member_info->find_account_question || !$member_info->find_account_answer) {
         return new Object(-1, 'msg_question_not_exists');
     }
     if (trim($member_info->find_account_question) != $find_account_question || trim($member_info->find_account_answer) != $find_account_answer) {
         return new Object(-1, 'msg_answer_not_matches');
     }
     if ($config->identifier == 'email_address') {
         $user_id = $email_address;
     }
     // Update to a temporary password and set change_password_date to 1
     $temp_password = Rhymix\Framework\Password::getRandomPassword(8);
     $args = new stdClass();
     $args->member_srl = $member_srl;
     $args->password = $temp_password;
     $args->change_password_date = '1';
     $output = $this->updateMemberPassword($args);
     if (!$output->toBool()) {
         return $output;
     }
     $_SESSION['xe_temp_password_' . $user_id] = $temp_password;
     $this->add('user_id', $user_id);
     $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', '');
     $this->setRedirectUrl($returnUrl . '&user_id=' . $user_id);
 }
Exemplo n.º 2
0
 public function createTemporaryPassword($length = 16)
 {
     return Rhymix\Framework\Password::getRandomPassword($length);
 }