feat: 소셜 회원가입 휴대폰번호 수집과 입력 및 저장 지원
네이버 공식 JSON 프로필 API와 카카오 계정 프로필에서 동의한 정보를 수집한다. 카카오 국내 국가번호를 변환하고, PC·모바일 가입 화면에 닉네임·이메일·휴대폰번호 순서로 입력란을 표시한다. 필수값과 번호 형식을 검증하고 본인확인 사용 여부와 관계없이 휴대폰번호를 저장한다. 기존 본인확인 해시 검증은 유지한다. 검증: PHP 문법 검사, 모의 검증 85개, diff 공백 검사 통과. 실제 OAuth 가입·DB 저장·SMS/LMS 수신은 미검증.
This commit is contained in:
@@ -91,13 +91,6 @@ $email_msg = $is_exists_email ? '등록할 이메일이 중복되었습니다.
|
||||
<?php if ($config["cf_cert_use"]) { ?>
|
||||
<input type="hidden" id="reg_mb_name" name="mb_name" value="<?php echo $user_name ? $user_name : $user_nick ?>">
|
||||
<?php } ?>
|
||||
<?php if ($config['cf_use_hp'] || ($config["cf_cert_use"] && ($config['cf_cert_hp'] || $config['cf_cert_simple']))) { ?>
|
||||
<input type="hidden" name="mb_hp" value="<?php echo get_text($user_phone); ?>" id="reg_mb_hp">
|
||||
<?php if ($config['cf_cert_use'] && ($config['cf_cert_hp'] || $config['cf_cert_simple'])) { ?>
|
||||
<input type="hidden" name="old_mb_hp" value="<?php echo get_text($user_phone); ?>">
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<div id="register_form" class="form_01">
|
||||
<h2>개인정보 입력</h2>
|
||||
<ul>
|
||||
@@ -142,6 +135,15 @@ $email_msg = $is_exists_email ? '등록할 이메일이 중복되었습니다.
|
||||
<input type="text" name="mb_email" value="<?php echo isset($user_email) ? $user_email : ''; ?>" id="reg_mb_email" required <?php echo (isset($user_email) && $user_email != '' && !$is_exists_email)? "readonly":''; ?> class="frm_input email full_input required" size="70" maxlength="100" placeholder="E-mail (필수)">
|
||||
<div class="check"><?php echo $email_msg; ?></div>
|
||||
</li>
|
||||
<?php if ($config['cf_use_hp'] || $config['cf_req_hp'] || ($config['cf_cert_use'] && ($config['cf_cert_hp'] || $config['cf_cert_simple']))) { ?>
|
||||
<li>
|
||||
<label for="reg_mb_hp">휴대폰번호<?php echo $config['cf_req_hp'] ? ' (필수)' : ''; ?></label>
|
||||
<input type="tel" name="mb_hp" value="<?php echo get_text($user_phone); ?>" id="reg_mb_hp" <?php echo $config['cf_req_hp'] ? 'required' : ''; ?> class="frm_input full_input <?php echo $config['cf_req_hp'] ? 'required' : ''; ?>" maxlength="20" placeholder="휴대폰번호">
|
||||
<?php if ($config['cf_cert_use'] && ($config['cf_cert_hp'] || $config['cf_cert_simple'])) { ?>
|
||||
<input type="hidden" name="old_mb_hp" value="<?php echo get_text($user_phone); ?>">
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -73,7 +73,7 @@ class Hybrid_Providers_Kakao extends Hybrid_Provider_Model_OAuth2
|
||||
function getUserProfile()
|
||||
{
|
||||
//$params = array('property_keys'=>'kaccount_email'); // v1 parameter
|
||||
$params = array('property_keys'=>array('kakao_account.email')); // v2 parameter
|
||||
$params = array('property_keys'=>json_encode(array('kakao_account.profile', 'kakao_account.email', 'kakao_account.phone_number'))); // v2 parameter
|
||||
|
||||
$this->api->decode_json = false;
|
||||
$this->api->curl_header = array( 'Authorization: Bearer ' . $this->api->access_token );
|
||||
@@ -85,8 +85,11 @@ class Hybrid_Providers_Kakao extends Hybrid_Provider_Model_OAuth2
|
||||
}
|
||||
# store the user profile.
|
||||
$this->user->profile->identifier = @ $data->id;
|
||||
$this->user->profile->displayName = @ $data->properties->nickname;
|
||||
$this->user->profile->photoURL = @ $data->properties->thumbnail_image;
|
||||
$this->user->profile->displayName = isset($data->kakao_account->profile->nickname) ? $data->kakao_account->profile->nickname : '';
|
||||
$this->user->profile->photoURL = isset($data->kakao_account->profile->thumbnail_image_url) ? $data->kakao_account->profile->thumbnail_image_url : '';
|
||||
$phone = isset($data->kakao_account->phone_number) ? $data->kakao_account->phone_number : '';
|
||||
// 국내 국가번호를 제거하고 생략된 맨 앞의 0을 복원한다.
|
||||
$this->user->profile->phone = preg_replace('/^\+82[\s-]*0?/', '0', trim($phone));
|
||||
//$email = @ $data->properties->kaccount_email; // v1 version
|
||||
|
||||
$email = @ $data->kakao_account->email; // v2 version
|
||||
|
||||
@@ -26,7 +26,7 @@ class Hybrid_Providers_Naver extends Hybrid_Provider_Model_OAuth2
|
||||
parent::initialize();
|
||||
|
||||
// Provider API end-points
|
||||
$this->api->api_base_url = "https://apis.naver.com/nidlogin/";
|
||||
$this->api->api_base_url = "https://openapi.naver.com/v1/";
|
||||
$this->api->authorize_url = "https://nid.naver.com/oauth2.0/authorize";
|
||||
$this->api->token_url = "https://nid.naver.com/oauth2.0/token";
|
||||
|
||||
@@ -102,18 +102,18 @@ class Hybrid_Providers_Naver extends Hybrid_Provider_Model_OAuth2
|
||||
//https://developers.naver.com/docs/login/profile/
|
||||
function getUserProfile()
|
||||
{
|
||||
$response = $this->profile("nid/getUserProfile.xml");
|
||||
$response = $this->profile("nid/me");
|
||||
$profile = json_decode($response, true);
|
||||
|
||||
$xml = @ new SimpleXMLElement($response);
|
||||
$data = array();
|
||||
if ( $xml->result[0]->resultcode == '00' ) {
|
||||
foreach ($xml->response->children() as $response => $k) {
|
||||
$data[(string)$response] = (string) $k;
|
||||
}
|
||||
} else {
|
||||
if (!is_array($profile) || !isset($profile['resultcode']) || $profile['resultcode'] !== '00'
|
||||
|| !isset($profile['response']) || !is_array($profile['response'])
|
||||
|| !isset($profile['response']['id']) || !is_string($profile['response']['id'])
|
||||
|| $profile['response']['id'] === '') {
|
||||
throw new Exception("User profile request failed! {$this->providerId} returned an invalid response.", 6);
|
||||
}
|
||||
|
||||
$data = $profile['response'];
|
||||
|
||||
# store the user profile.
|
||||
//$this->user->profile->identifier = (array_key_exists('enc_id',$data))?$data['enc_id']:"";
|
||||
$this->user->profile->identifier = (array_key_exists('id',$data))?$data['id']:"";
|
||||
@@ -139,6 +139,7 @@ class Hybrid_Providers_Naver extends Hybrid_Provider_Model_OAuth2
|
||||
}
|
||||
$this->user->profile->email = (array_key_exists('email',$data))?$data['email']:"";
|
||||
$this->user->profile->emailVerified = (array_key_exists('email',$data))?$data['email']:"";
|
||||
$this->user->profile->phone = (array_key_exists('mobile', $data)) ? $data['mobile'] : '';
|
||||
$this->user->profile->gender = (array_key_exists('gender',$data))?(($data['gender'] == "M")?"male":"female"):"";
|
||||
$this->user->profile->photoURL = (array_key_exists('profile_image',$data))?$data['profile_image']:"";
|
||||
|
||||
|
||||
@@ -25,7 +25,8 @@ $is_exists_social_account = social_before_join_check($url);
|
||||
$user_nick = social_relace_nick($user_profile->displayName);
|
||||
$user_email = isset($user_profile->emailVerified) ? $user_profile->emailVerified : $user_profile->email;
|
||||
$user_id = $user_profile->sid ? preg_replace("/[^0-9a-z_]+/i", "", $user_profile->sid) : get_social_convert_id($user_profile->identifier, $provider_name);
|
||||
$user_phone = $user_profile->phone;
|
||||
$user_phone = isset($user_profile->phone) ? $user_profile->phone : '';
|
||||
$user_phone = valid_mb_hp($user_phone) ? '' : hyphen_hp_number($user_phone);
|
||||
|
||||
if(! $user_nick) {
|
||||
$tmp = explode('_', $user_id);
|
||||
|
||||
@@ -31,7 +31,17 @@ $mb_password_re = isset($_POST['mb_password_re']) ? trim($_POST['mb_password_re'
|
||||
$mb_nick = isset($_POST['mb_nick']) ? trim(strip_tags($_POST['mb_nick'])) : '';
|
||||
$mb_email = isset($_POST['mb_email']) ? trim($_POST['mb_email']) : '';
|
||||
$mb_name = isset($_POST['mb_name']) ? addslashes(clean_xss_tags(trim(strip_tags(stripslashes($_POST['mb_name']))))) : '';
|
||||
$mb_hp = isset($_POST['mb_hp']) ? trim($_POST['mb_hp']) : '';
|
||||
// 입력값이 없는 기존 스킨에서도 동의하여 제공받은 휴대폰번호를 활용한다.
|
||||
$profile_phone = isset($user_profile->phone) ? $user_profile->phone : '';
|
||||
$profile_phone = valid_mb_hp($profile_phone) ? '' : $profile_phone;
|
||||
if (isset($_POST['mb_hp']) && !is_string($_POST['mb_hp'])) {
|
||||
alert('휴대폰번호를 올바르게 입력해 주십시오.', '', true, true);
|
||||
}
|
||||
$mb_hp = isset($_POST['mb_hp']) ? trim($_POST['mb_hp']) : $profile_phone;
|
||||
if ($config['cf_req_hp'] || $mb_hp !== '') {
|
||||
if ($msg = valid_mb_hp($mb_hp)) alert($msg, '', true, true);
|
||||
}
|
||||
$mb_hp = hyphen_hp_number($mb_hp);
|
||||
$mb_email = get_email_address($mb_email);
|
||||
|
||||
// 이름, 닉네임에 utf-8 이외의 문자가 포함됐다면 오류
|
||||
@@ -141,8 +151,10 @@ if (!empty($agree_items)) {
|
||||
//===============================================================
|
||||
// 본인확인
|
||||
//---------------------------------------------------------------
|
||||
$sql_certify = '';
|
||||
$md5_cert_no = '';
|
||||
$cert_type = '';
|
||||
if($config['cf_cert_use']) {
|
||||
$mb_hp = hyphen_hp_number($mb_hp);
|
||||
if($config['cf_cert_use'] && get_session('ss_cert_type') && get_session('ss_cert_dupinfo')) {
|
||||
// 중복체크
|
||||
$sql = " select mb_id from {$g5['member_table']} where mb_id <> '{$member['mb_id']}' and mb_dupinfo = '".get_session('ss_cert_dupinfo')."' ";
|
||||
@@ -158,7 +170,6 @@ if($config['cf_cert_use']) {
|
||||
if ($config['cf_cert_use'] && $cert_type && $md5_cert_no) {
|
||||
// 해시값이 같은 경우에만 본인확인 값을 저장한다.
|
||||
if ($cert_type == 'ipin' && get_session('ss_cert_hash') == md5($mb_name.$cert_type.get_session('ss_cert_birth').$md5_cert_no)) { // 아이핀일때 hash 값 체크 hp미포함
|
||||
$sql_certify .= " , mb_hp = '{$mb_hp}' ";
|
||||
$sql_certify .= " , mb_certify = '{$cert_type}' ";
|
||||
$sql_certify .= " , mb_adult = '".get_session('ss_cert_adult')."' ";
|
||||
$sql_certify .= " , mb_birth = '".get_session('ss_cert_birth')."' ";
|
||||
@@ -167,7 +178,6 @@ if($config['cf_cert_use']) {
|
||||
if($w == 'u')
|
||||
$sql_certify .= " , mb_name = '{$mb_name}' ";
|
||||
} else if($cert_type != 'ipin' && get_session('ss_cert_hash') == md5($mb_name.$cert_type.get_session('ss_cert_birth').$mb_hp.$md5_cert_no)) { // 간편인증, 휴대폰일때 hash 값 체크 hp포함
|
||||
$sql_certify .= " , mb_hp = '{$mb_hp}' ";
|
||||
$sql_certify .= " , mb_certify = '{$cert_type}' ";
|
||||
$sql_certify .= " , mb_adult = '".get_session('ss_cert_adult')."' ";
|
||||
$sql_certify .= " , mb_birth = '".get_session('ss_cert_birth')."' ";
|
||||
@@ -180,7 +190,6 @@ if($config['cf_cert_use']) {
|
||||
}
|
||||
} else {
|
||||
if (get_session("ss_reg_mb_name") != $mb_name || get_session("ss_reg_mb_hp") != $mb_hp) {
|
||||
$sql_certify .= " , mb_hp = '{$mb_hp}' ";
|
||||
$sql_certify .= " , mb_certify = '' ";
|
||||
$sql_certify .= " , mb_adult = 0 ";
|
||||
$sql_certify .= " , mb_birth = '' ";
|
||||
@@ -197,6 +206,7 @@ $sql = " insert into {$g5['member_table']}
|
||||
mb_nick = '{$mb_nick}',
|
||||
mb_nick_date = '".G5_TIME_YMD."',
|
||||
mb_email = '{$mb_email}',
|
||||
mb_hp = '{$mb_hp}',
|
||||
mb_email_certify = '".$mb_email_certify."',
|
||||
mb_today_login = '".G5_TIME_YMDHIS."',
|
||||
mb_datetime = '".G5_TIME_YMDHIS."',
|
||||
|
||||
@@ -83,13 +83,6 @@ $email_msg = $is_exists_email ? '등록할 이메일이 중복되었습니다.
|
||||
<?php if ($config["cf_cert_use"]) { ?>
|
||||
<input type="hidden" id="reg_mb_name" name="mb_name" value="<?php echo $user_name ? $user_name : $user_nick ?>">
|
||||
<?php } ?>
|
||||
<?php if ($config['cf_use_hp'] || ($config["cf_cert_use"] && ($config['cf_cert_hp'] || $config['cf_cert_simple']))) { ?>
|
||||
<input type="hidden" name="mb_hp" value="<?php echo get_text($user_phone); ?>" id="reg_mb_hp">
|
||||
<?php if ($config['cf_cert_use'] && ($config['cf_cert_hp'] || $config['cf_cert_simple'])) { ?>
|
||||
<input type="hidden" name="old_mb_hp" value="<?php echo get_text($user_phone); ?>">
|
||||
<?php } ?>
|
||||
<?php } ?>
|
||||
|
||||
<div id="register_form" class="form_01">
|
||||
<div class="tbl_frm01 tbl_wrap register_form_inner">
|
||||
<h2>개인정보 입력</h2>
|
||||
@@ -142,6 +135,15 @@ $email_msg = $is_exists_email ? '등록할 이메일이 중복되었습니다.
|
||||
<input type="text" name="mb_email" value="<?php echo isset($user_email) ? $user_email : ''; ?>" id="reg_mb_email" required <?php echo (isset($user_email) && $user_email != '' && !$is_exists_email)? "readonly":''; ?> class="frm_input email full_input required" size="70" maxlength="100" placeholder="E-mail">
|
||||
<div class="check"><?php echo $email_msg; ?></div>
|
||||
</li>
|
||||
<?php if ($config['cf_use_hp'] || $config['cf_req_hp'] || ($config['cf_cert_use'] && ($config['cf_cert_hp'] || $config['cf_cert_simple']))) { ?>
|
||||
<li>
|
||||
<label for="reg_mb_hp">휴대폰번호<?php echo $config['cf_req_hp'] ? ' (필수)' : ''; ?></label>
|
||||
<input type="tel" name="mb_hp" value="<?php echo get_text($user_phone); ?>" id="reg_mb_hp" <?php echo $config['cf_req_hp'] ? 'required' : ''; ?> class="frm_input full_input <?php echo $config['cf_req_hp'] ? 'required' : ''; ?>" maxlength="20" placeholder="휴대폰번호">
|
||||
<?php if ($config['cf_cert_use'] && ($config['cf_cert_hp'] || $config['cf_cert_simple'])) { ?>
|
||||
<input type="hidden" name="old_mb_hp" value="<?php echo get_text($user_phone); ?>">
|
||||
<?php } ?>
|
||||
</li>
|
||||
<?php } ?>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user