/** * 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); }
public function createTemporaryPassword($length = 16) { return Rhymix\Framework\Password::getRandomPassword($length); }
/** * Implement if additional tasks are necessary when installing * * @return Object */ function moduleInstall() { // Register action forward (to use in administrator mode) $oModuleController = getController('module'); $oDB =& DB::getInstance(); $oDB->addIndex("member_group", "idx_site_title", array("site_srl", "title"), true); $oModuleModel = getModel('module'); $config = $oModuleModel->getModuleConfig('member'); if (empty($config)) { $isNotInstall = true; $config = new stdClass(); } // Set the basic information $config->enable_join = 'Y'; $config->enable_openid = 'N'; if (!$config->enable_auth_mail) { $config->enable_auth_mail = 'N'; } if (!$config->image_name) { $config->image_name = 'Y'; } if (!$config->image_mark) { $config->image_mark = 'Y'; } if (!$config->profile_image) { $config->profile_image = 'Y'; } if (!$config->image_name_max_width) { $config->image_name_max_width = '90'; } if (!$config->image_name_max_height) { $config->image_name_max_height = '20'; } if (!$config->image_mark_max_width) { $config->image_mark_max_width = '20'; } if (!$config->image_mark_max_height) { $config->image_mark_max_height = '20'; } if (!$config->profile_image_max_width) { $config->profile_image_max_width = '90'; } if (!$config->profile_image_max_height) { $config->profile_image_max_height = '90'; } if ($config->group_image_mark != 'Y') { $config->group_image_mark = 'N'; } if (!$config->password_strength) { $config->password_strength = 'normal'; } if (!$config->password_hashing_algorithm) { $config->password_hashing_algorithm = Rhymix\Framework\Password::getBestSupportedAlgorithm(); } if (!$config->password_hashing_work_factor) { $config->password_hashing_work_factor = 8; } if (!$config->password_hashing_auto_upgrade) { $config->password_hashing_auto_upgrade = 'Y'; } global $lang; $oMemberModel = getModel('member'); // Create a member controller object $oMemberController = getController('member'); $oMemberAdminController = getAdminController('member'); if (!$config->signupForm || !is_array($config->signupForm)) { $identifier = 'user_id'; $config->signupForm = $oMemberAdminController->createSignupForm($identifier); $config->identifier = $identifier; // Create Ruleset File FileHandler::makeDir('./files/ruleset'); $oMemberAdminController->_createSignupRuleset($config->signupForm); $oMemberAdminController->_createLoginRuleset($config->identifier); $oMemberAdminController->_createFindAccountByQuestion($config->identifier); } $oModuleController->insertModuleConfig('member', $config); $groups = $oMemberModel->getGroups(); if (!count($groups)) { // Set an administrator, regular member(group1), and associate member(group2) $group_args = new stdClass(); $group_args->title = lang('admin_group'); $group_args->is_default = 'N'; $group_args->is_admin = 'Y'; $output = $oMemberAdminController->insertGroup($group_args); $group_args = new stdClass(); $group_args->title = lang('default_group_1'); $group_args->is_default = 'Y'; $group_args->is_admin = 'N'; $output = $oMemberAdminController->insertGroup($group_args); $group_args = new stdClass(); $group_args->title = lang('default_group_2'); $group_args->is_default = 'N'; $group_args->is_admin = 'N'; $oMemberAdminController->insertGroup($group_args); } // Configure administrator information $admin_args = new stdClass(); $admin_args->is_admin = 'Y'; $output = executeQuery('member.getMemberList', $admin_args); if (!$output->data) { $admin_info = Context::gets('password', 'nick_name', 'email_address', 'user_id'); if ($admin_info->email_address) { $admin_info->user_name = 'admin'; // Insert admin information $oMemberAdminController->insertAdmin($admin_info); // Log-in Processing $output = $oMemberController->doLogin($admin_info->email_address); } } // Register denied ID(default + module name) $oModuleModel = getModel('module'); $module_list = $oModuleModel->getModuleList(); foreach ($module_list as $key => $val) { $oMemberAdminController->insertDeniedID($val->module, ''); } $oMemberAdminController->insertDeniedID('www', ''); $oMemberAdminController->insertDeniedID('root', ''); $oMemberAdminController->insertDeniedID('administrator', ''); $oMemberAdminController->insertDeniedID('telnet', ''); $oMemberAdminController->insertDeniedID('ftp', ''); $oMemberAdminController->insertDeniedID('http', ''); // Create cache directory to use in the member module FileHandler::makeDir('./files/member_extra_info/image_name'); FileHandler::makeDir('./files/member_extra_info/image_mark'); FileHandler::makeDir('./files/member_extra_info/profile_image'); FileHandler::makeDir('./files/member_extra_info/signature'); // 2013. 11. 22 add menu when popup document menu called $oModuleController->insertTrigger('document.getDocumentMenu', 'member', 'controller', 'triggerGetDocumentMenu', 'after'); $oModuleController->insertTrigger('comment.getCommentMenu', 'member', 'controller', 'triggerGetCommentMenu', 'after'); return new Object(); }
/** * @brief Create a hash of plain text password * @param string $password_text The password to hash * @param string $algorithm The algorithm to use (optional, only set this when you want to use a non-default algorithm) * @return string */ function hashPassword($password_text, $algorithm = null) { return Rhymix\Framework\Password::hashPassword($password_text, $algorithm); }
public function procMemberAdminInsertDefaultConfig() { $args = Context::gets('enable_join', 'enable_confirm', 'enable_find_account_question', 'webmaster_name', 'webmaster_email', 'password_strength', 'password_hashing_algorithm', 'password_hashing_work_factor', 'password_hashing_auto_upgrade', 'update_nickname_log', 'member_allow_fileupload'); if (!array_key_exists($args->password_hashing_algorithm, Rhymix\Framework\Password::getSupportedAlgorithms())) { $args->password_hashing_algorithm = 'md5'; } $args->password_hashing_work_factor = intval($args->password_hashing_work_factor, 10); if ($args->password_hashing_work_factor < 4) { $args->password_hashing_work_factor = 4; } if ($args->password_hashing_work_factor > 16) { $args->password_hashing_work_factor = 16; } if ($args->password_hashing_auto_upgrade != 'Y') { $args->password_hashing_auto_upgrade = 'N'; } if ((!$args->webmaster_name || !$args->webmaster_email) && $args->enable_confirm == 'Y') { return new Object(-1, 'msg_mail_authorization'); } $oModuleController = getController('module'); $output = $oModuleController->updateModuleConfig('member', $args); // default setting end $this->setMessage('success_updated'); $returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'module', 'admin', 'act', 'dispMemberAdminDefaultConfig'); $this->setRedirectUrl($returnUrl); }
/** * Set the default config. * * @return void */ public function dispMemberAdminConfig() { Context::set('password_hashing_algos', Rhymix\Framework\Password::getSupportedAlgorithms()); $this->setTemplateFile('default_config'); }