묻고답하기
외부컨테이너에서 로그인가능하게 어떻게개조하죠?
2012.01.30 17:24
에
늅입니다.
그러니까 간단하게
복잡한거 다생략하고
외부컨테이너에서 기존 xe의 로그인을 인식하는 member.controller 파일을 바꾼
임의의 파일로 값을 전송해서 그곳에서 그 값을 읽고 로그인처리하는
어떻게 수정하나요..?
function procMemberLogin($user_id = null, $password = null, $keep_signed = null) {
// Variables
if(!$user_id) $user_id = Context::get('user_id'+
');
$user_id = trim($user_id);
if(!$password) $password = Context::get('password');
$password = trim($password);
if(!$keep_signed) $keep_signed = Context::get('keep_signed');
// Return an error when id and password doesn't exist
if(!$user_id) return new Object(-1,'null_user_id');
if(!$password) return new Object(-1,'null_password');
$output = $this->doLogin($user_id, $password, $keep_signed=='Y'?true:false);
if (!$output->toBool()) return $output;
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('member');
// Check change_password_date
$limit_date = $config->change_password_date;
// Check if change_password_date is set
if ($limit_date > 0) {
$oMemberModel = &getModel('member');
//$member_info = $oMemberModel->getMemberInfoByUserID($user_id, $columnList);
if ($this->memberInfo->change_password_date < date ('YmdHis', strtotime ('-' . $limit_date . ' day'+
'))) {
$this->setRedirectUrl(getNotEncodedUrl('','vid',Context::get('vid'),'mid',Context::get('mid'),'act','dispMemberModifyPassword'));
}
}
if(!in_array(Context::getRequestMethod(),array('XMLRPC','JSON'))) {
if(!$config->after_login_url) {
$returnUrl = Context::get('success_return_url') ? Context::get('success_return_url') : getNotEncodedUrl('', 'mid', Context::get('mid'), 'act', ''+
');
} else {
$returnUrl = $config->after_login_url;
}
$this->setRedirectUrl($returnUrl);
return;
}
return $output;
}
/**
* @brief Login by openid
**/
function procMemberOpenIDLogin($validator = "procMemberOpenIDValidate") {
$oModuleModel = &getModel('module');
$config = $oModuleModel->getModuleConfig('member');
if($config->enable_openid != 'Y') $this->stop('msg_invalid_request');
if(!defined('Auth_OpenID_RAND_SOURCE') && !file_exists("/dev/urandom"))
{
define('Auth_OpenID_RAND_SOURCE', null);
}
set_include_path(_XE_PATH_."modules/member/php-openid-1.2.3");
require_once('Auth/OpenID.php');
require_once('Auth/OpenID/Consumer.php');
require_once('Auth/OpenID/XEStore.php');
$store = new Auth_OpenID_XEStore();
$consumer = new Auth_OpenID_Consumer($store);
$user_id = Context::get('user_id');
if (!$user_id) $user_id = Context::get('openid');
$auth_request = $consumer->begin($user_id);
$auth_request->addExtensionArg('sreg', 'required', 'email');
$auth_request->addExtensionArg('sreg', 'optional', 'dob');
if(!$auth_request)
{
return new Object(-1, "association failed");
}
$trust_root = 'http://'.$_SERVER["HTTP_HOST"];
$referer_url = Context::get('referer_url');
if (!$referer_url) $referer_url = $_SERVER['HTTP_REFERER'];
if (!$referer_url)
$referer_url = htmlspecialchars_decode(getRequestUri(RELEASE_SSL));
$goto = urlencode($referer_url);
$ApprovedURL = Context::getRequestUri(RELEASE_SSL) . "?module=member&act=" . $validator. "&goto=" . $goto;
$redirect_url = $auth_request->redirectURL($trust_root, $ApprovedURL);
$this->add("redirect_url", $redirect_url);
if (Context::getRequestMethod() == 'POST')
header("location:" . $redirect_url);
}
function getLegacyUserIDsFromOpenID($openid_identity) {
// Issue 17515512: workaround
$result = array();
$uri_matches = array();
preg_match(Auth_OpenID_getURIPattern(), $openid_identity, $uri_matches);
if (count($uri_matches) < 9) {
for ($i = count($uri_matches); $i <= 9; $i++) {
$uri_matches[] = '';
}
}
$scheme = $uri_matches[2];
$authority = $uri_matches[4];
$path = $uri_matches[5];
$query = $uri_matches[6];
$fragment = $uri_matches[8];
if ($scheme === null) $scheme = '';
if ($authority === null) $authority = '';
if ($path === null) $path = '';
if ($query === null) $query = '';
if ($fragment === null) $fragment = '';
if ($scheme == 'http' or $scheme == '')
$scheme_part = '';
else
$scheme_part = $scheme."://";
if ($path == '' || $path == '/') {
$result[] = $scheme_part.$authority.''.$query.$fragment;
$result[] = $scheme_part.$authority.'/'.$query.$fragment;
}
else {
$result[] = $scheme_part.$authority.$path.$query.$fragment;
}
return $result;
}
/**
* @brief openid authentication check
**/
function procMemberOpenIDValidate() {
set_include_path(_XE_PATH_."modules/member/php-openid-1.2.3");
require_once('Auth/OpenID.php');
require_once('Auth/OpenID/Consumer.php');
require_once('Auth/OpenID/XEStore.php');
require_once('Auth/OpenID/URINorm.php');
$store = new Auth_OpenID_XEStore();
$consumer = new Auth_OpenID_Consumer($store);
$response = $consumer->complete($_GET);
switch($response->status) {
case Auth_OpenID_CANCEL :
// Handle if user authentication is canceled
return $this->stop('authorization_canceled');
case Auth_OpenID_FAILURE :
// Handle if user authentication is failed due to a certain problem (for example, openid doesn't exist) (there is no authentication required deunga openid ..)
return $this->stop('invalid_authorization');
case Auth_OpenID_SUCCESS :
// Authentication success!
break;
default:
return $this->stop('invalid_authorization');
}
// Authentication success
$oMemberModel = &getModel('member');
// Get zeroboard ID which is corresponded to the openID ID.
$login_success = false;
$assoc_member_info = null;
$openid_identity = $response->signed_args["openid.identity"];
$args->openid = $openid_identity;
$output = executeQuery('member.getMemberSrlByOpenID', $args);
if ($output->toBool() && $output->data && !is_array($output->data)) {
$member_srl = $output->data->member_srl;
$columnList = array('member_srl', 'user_id');
$member_info = $oMemberModel->getMemberInfoByMemberSrl($member_srl, 0, $columnList);
if ($member_info) {
$assoc_member_info = $member_info;
}
}
$user_id_candidates = $this->getLegacyUserIDsFromOpenID($openid_identity);
$default_user_id = $user_id_candidates[0];
if ($assoc_member_info != null) {
$user_id_candidates = array_merge(array($assoc_member_info->user_id), $user_id_candidates);
}
$sreg = $response->extensionResponse('sreg');
foreach($user_id_candidates as $user_id) {
$args->user_id = $args->nick_name = $user_id;
// Get basic information
$args->email_address = $sreg['email'];
$args->user_name = $sreg['fullname'];
if(!$args->user_name) list($args->user_name) = explode('@', $args->email_address);
$args->birthday = str_replace('-','',$sreg['dob']);
// Attempts self-authentication
$output = $this->doLogin($args->user_id);
if ($output->toBool()) {
if ($assoc_member_info == null) {
$logged_info = Context::get('logged_info');
$args->member_srl = $logged_info->member_srl;
$args->openid = $openid_identity;
executeQuery('member.addOpenIDToMember', $args);
}
$login_success = true;
break;
}
}
막막한거압니다.
예전에 zb4에서는 수정이 간단했는데
이건 뭐..
쿼리에서 값을받아오고 대조하고
로그인여부와 IP,member_srl 다른 쿼리값을 echo로 외부컨테이너로 전송시키려면
어떻게수정해야하나요? ㅜㅜㅜ