diff --git a/i_entrance/j_get_user_info.php b/i_entrance/j_get_user_info.php
index a3c291ac..757bf350 100644
--- a/i_entrance/j_get_user_info.php
+++ b/i_entrance/j_get_user_info.php
@@ -9,7 +9,7 @@ $userID = Session::getUserID();
// 외부 파라미터
$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']){
$picture = ServConfig::getSharedIconPath().'/default.jpg';
@@ -30,6 +30,9 @@ else{
}
}
+$oauthInfo = Json::decode($member['oauth_info'])??[];
+$loginTokenValid = $oauthInfo['OTPValidUntil']??null;
+
if($member['grade'] == 6) {
$grade = '운영자';
} elseif($member['grade'] == 5) {
@@ -81,5 +84,8 @@ Json::die([
'global_salt'=>RootDB::getGlobalSalt(),
'join_date'=>$member['reg_date'],
'third_use'=>($member['third_use']!=0),
- 'acl'=>$acl
+ 'acl'=>$acl,
+ 'oauth_type'=>$member['oauth_type'],
+ 'login_token_valid'=>$loginTokenValid
+
]);
diff --git a/i_entrance/user_info.php b/i_entrance/user_info.php
index fa046738..7203a283 100644
--- a/i_entrance/user_info.php
+++ b/i_entrance/user_info.php
@@ -23,6 +23,7 @@ require(__dir__.'/../vendor/autoload.php');
=WebUtil::printJS('../e_lib/jquery-3.3.1.min.js')?>
=WebUtil::printJS('../e_lib/bootstrap.bundle.min.js')?>
=WebUtil::printJS('../e_lib/sha512.min.js')?>
+ =WebUtil::printJS('../e_lib/moment.min.js')?>
=WebUtil::printJS('../js/func.js')?>
=WebUtil::printJS('../js/user_info.js')?>
=WebUtil::printJS('../d_shared/menu.js')?>
@@ -87,6 +88,14 @@ require(__dir__.'/../vendor/autoload.php');
개인정보 3자 제공 동의 : |
+
+ | 인증 방식 |
+
+
+ |
+
+ 까지 유효 |
+
|
회원 탈퇴 |
diff --git a/js/user_info.js b/js/user_info.js
index 027473b5..0ed86887 100644
--- a/js/user_info.js
+++ b/js/user_info.js
@@ -20,6 +20,16 @@ function fillUserInfo(result){
if(result.third_use){
$('#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(){
@@ -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(){
$('#slot_icon, #slot_new_icon').attr('src', pathConfig.sharedIcon+'/default.jpg');
$.ajax({
@@ -255,4 +296,6 @@ $(function(){
deleteMe(e);
}
});
+
+ $('#expand_login_token').click(extendAuth);
})
diff --git a/oauth_kakao/j_reset_token.php b/oauth_kakao/j_reset_token.php
new file mode 100644
index 00000000..d8abaa11
--- /dev/null
+++ b/oauth_kakao/j_reset_token.php
@@ -0,0 +1,45 @@
+'로그인이 되어있지 않습니다'
+]);
+
+
+$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'=>'초기화 완료.'
+]);