5일이 지난후 로그인 토큰을 미리 초기화 가능하도록 수정
This commit is contained in:
@@ -9,7 +9,7 @@ $userID = Session::getUserID();
|
|||||||
// 외부 파라미터
|
// 외부 파라미터
|
||||||
|
|
||||||
$db = RootDB::db();
|
$db = RootDB::db();
|
||||||
$member = $db->queryFirstRow('SELECT `id`, `name`, `grade`, `picture`, reg_date, third_use, acl FROM `member` WHERE `NO` = %i', $userID);
|
$member = $db->queryFirstRow('SELECT `id`, `name`, `grade`, `picture`, reg_date, third_use, acl, oauth_type, oauth_info FROM `member` WHERE `NO` = %i', $userID);
|
||||||
|
|
||||||
if(!$member['picture']){
|
if(!$member['picture']){
|
||||||
$picture = ServConfig::getSharedIconPath().'/default.jpg';
|
$picture = ServConfig::getSharedIconPath().'/default.jpg';
|
||||||
@@ -30,6 +30,9 @@ else{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$oauthInfo = Json::decode($member['oauth_info'])??[];
|
||||||
|
$loginTokenValid = $oauthInfo['OTPValidUntil']??null;
|
||||||
|
|
||||||
if($member['grade'] == 6) {
|
if($member['grade'] == 6) {
|
||||||
$grade = '운영자';
|
$grade = '운영자';
|
||||||
} elseif($member['grade'] == 5) {
|
} elseif($member['grade'] == 5) {
|
||||||
@@ -81,5 +84,8 @@ Json::die([
|
|||||||
'global_salt'=>RootDB::getGlobalSalt(),
|
'global_salt'=>RootDB::getGlobalSalt(),
|
||||||
'join_date'=>$member['reg_date'],
|
'join_date'=>$member['reg_date'],
|
||||||
'third_use'=>($member['third_use']!=0),
|
'third_use'=>($member['third_use']!=0),
|
||||||
'acl'=>$acl
|
'acl'=>$acl,
|
||||||
|
'oauth_type'=>$member['oauth_type'],
|
||||||
|
'login_token_valid'=>$loginTokenValid
|
||||||
|
|
||||||
]);
|
]);
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ require(__dir__.'/../vendor/autoload.php');
|
|||||||
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
<?=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
|
||||||
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
<?=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
|
||||||
<?=WebUtil::printJS('../e_lib/sha512.min.js')?>
|
<?=WebUtil::printJS('../e_lib/sha512.min.js')?>
|
||||||
|
<?=WebUtil::printJS('../e_lib/moment.min.js')?>
|
||||||
<?=WebUtil::printJS('../js/func.js')?>
|
<?=WebUtil::printJS('../js/func.js')?>
|
||||||
<?=WebUtil::printJS('../js/user_info.js')?>
|
<?=WebUtil::printJS('../js/user_info.js')?>
|
||||||
<?=WebUtil::printJS('../d_shared/menu.js')?>
|
<?=WebUtil::printJS('../d_shared/menu.js')?>
|
||||||
@@ -87,6 +88,14 @@ require(__dir__.'/../vendor/autoload.php');
|
|||||||
</td>
|
</td>
|
||||||
<td colspan="3">개인정보 3자 제공 동의 : <span id="slot_third_use"></span><button type="button" id="third_use_disallow">철회</button></td>
|
<td colspan="3">개인정보 3자 제공 동의 : <span id="slot_third_use"></span><button type="button" id="third_use_disallow">철회</button></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th class="bg1">인증 방식</th>
|
||||||
|
<td colspan="2">
|
||||||
|
<span id="slot_oauth_type"></span>
|
||||||
|
</td>
|
||||||
|
<td colspan="3">
|
||||||
|
<span id="slot_token_valid_until"></span>까지 유효<button type="button" id="expand_login_token">초기화</button></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<th class="bg1"></th>
|
<th class="bg1"></th>
|
||||||
<th class="bg1" colspan="2">회원 탈퇴</th>
|
<th class="bg1" colspan="2">회원 탈퇴</th>
|
||||||
|
|||||||
@@ -20,6 +20,16 @@ function fillUserInfo(result){
|
|||||||
if(result.third_use){
|
if(result.third_use){
|
||||||
$('#third_use_disallow').show();
|
$('#third_use_disallow').show();
|
||||||
}
|
}
|
||||||
|
$('#slot_oauth_type').text(result.oauth_type);
|
||||||
|
if(result.oauth_type != 'NONE'){
|
||||||
|
$('#slot_token_valid_until').text(result.login_token_valid);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
$('#slot_token_valid_until').parent().html('');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function changeIconPreview(){
|
function changeIconPreview(){
|
||||||
@@ -217,6 +227,37 @@ function deleteMe(){
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function extendAuth(){
|
||||||
|
var validUntil = $('#slot_token_valid_until').html();
|
||||||
|
var availableAt = moment(validUntil).subtract(5, 'days').format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
var now = moment().format('YYYY-MM-DD HH:mm:ss');
|
||||||
|
|
||||||
|
if(now < availableAt){
|
||||||
|
alert('{0}부터 초기화할 수 있습니다.'.format(availableAt));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!confirm('로그아웃됩니다. 진행할까요?')){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$.ajax({
|
||||||
|
type:'post',
|
||||||
|
url:'../oauth_kakao/j_reset_token.php',
|
||||||
|
dataType:'json',
|
||||||
|
}).then(function(result){
|
||||||
|
if(!result.result){
|
||||||
|
alert(result.reason);
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
alert('초기화했습니다. 다시 로그인해 주십시오.');
|
||||||
|
location.href='../';
|
||||||
|
}
|
||||||
|
},function(){
|
||||||
|
alert('알 수 없는 이유로 로그인 토큰 연장에 실패했습니다.');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$(function(){
|
$(function(){
|
||||||
$('#slot_icon, #slot_new_icon').attr('src', pathConfig.sharedIcon+'/default.jpg');
|
$('#slot_icon, #slot_new_icon').attr('src', pathConfig.sharedIcon+'/default.jpg');
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -255,4 +296,6 @@ $(function(){
|
|||||||
deleteMe(e);
|
deleteMe(e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
$('#expand_login_token').click(extendAuth);
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
namespace sammo;
|
||||||
|
|
||||||
|
require(__dir__.'/../vendor/autoload.php');
|
||||||
|
|
||||||
|
use \kakao\Kakao_REST_API_Helper as Kakao_REST_API_Helper;
|
||||||
|
|
||||||
|
$session = Session::requireLogin([
|
||||||
|
'reason'=>'로그인이 되어있지 않습니다'
|
||||||
|
]);
|
||||||
|
|
||||||
|
|
||||||
|
$userID = Session::getUserID();
|
||||||
|
|
||||||
|
$oauthInfo = Json::decode(RootDB::db()->queryFirstField('SELECT oauth_info from member where no=%i',$userID))??[];
|
||||||
|
if(!$oauthInfo){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'초기화 가능한 로그인 상태가 아닙니다.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
$OTPValidUntil = $oauthInfo['OTPValidUntil']??null;
|
||||||
|
|
||||||
|
$now = TimeUtil::DatetimeNow();
|
||||||
|
$expectedDate = TimeUtil::DatetimeFromNowDay(5);
|
||||||
|
|
||||||
|
if($expectedDate <= $OTPValidUntil){
|
||||||
|
Json::die([
|
||||||
|
'result'=>false,
|
||||||
|
'reason'=>'아직 연장 가능하지 않습니다.'
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
unset($oauthInfo['OTPValidUntil']);
|
||||||
|
RootDB::db()->update('member', [
|
||||||
|
'oauth_info'=>Json::encode($oauthInfo)
|
||||||
|
], 'no=%i', $userID);
|
||||||
|
|
||||||
|
$session->logout();
|
||||||
|
|
||||||
|
Json::die([
|
||||||
|
'result'=>true,
|
||||||
|
'reason'=>'초기화 완료.'
|
||||||
|
]);
|
||||||
Reference in New Issue
Block a user