oauth 인증중 token_valid_until만 table column으로 분리
This commit is contained in:
@@ -78,15 +78,15 @@ if($OTPValue != $otp){
|
||||
]);
|
||||
}
|
||||
|
||||
$OTPValidUntil = TimeUtil::DatetimeFromNowDay(10);
|
||||
$tokenValidUntil = TimeUtil::DatetimeFromNowDay(10);
|
||||
$session->setReqOTP(false);
|
||||
$oauthInfo['OTPValidUntil'] = $OTPValidUntil;
|
||||
RootDB::db()->update('member', [
|
||||
'oauth_info'=>Json::encode($oauthInfo)
|
||||
'oauth_info'=>Json::encode($oauthInfo),
|
||||
'token_valid_until'=>$tokenValidUntil,
|
||||
], 'no=%i', $userNo);
|
||||
|
||||
Json::die([
|
||||
'result'=>true,
|
||||
'reset'=>false,
|
||||
'reason'=>"로그인을 성공했습니다. {$OTPValidUntil}까지 유효합니다."
|
||||
'reason'=>"로그인을 성공했습니다. {$tokenValidUntil}까지 유효합니다."
|
||||
]);
|
||||
@@ -117,7 +117,7 @@ if(!$email){
|
||||
|
||||
|
||||
$userInfo = $RootDB->queryFirstRow(
|
||||
'SELECT `no`, `id`, `name`, `grade`, `delete_after`, `acl`, oauth_info from member where email=%s',$email);
|
||||
'SELECT `no`, `id`, `name`, `grade`, `delete_after`, `acl`, oauth_info, token_valid_until from member where email=%s',$email);
|
||||
|
||||
if(!$userInfo){
|
||||
$restAPI->unlink();
|
||||
@@ -164,9 +164,9 @@ RootDB::db()->update('member', [
|
||||
], 'no=%i', $userInfo['no']);
|
||||
|
||||
|
||||
$OTPValidUntil = $oauthInfo['OTPValidUntil']??null;
|
||||
$tokenValidUntil = $userInfo['token_valid_until'];
|
||||
|
||||
if(!$OTPValidUntil || $OTPValidUntil < $now){
|
||||
if(!$tokenValidUntil || $tokenValidUntil < $now){
|
||||
if(!createOTPbyUserNO($userInfo['no'])){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
|
||||
@@ -12,29 +12,28 @@ $session = Session::requireLogin([
|
||||
|
||||
$userID = Session::getUserID();
|
||||
|
||||
$oauthInfo = Json::decode(RootDB::db()->queryFirstField('SELECT oauth_info from member where no=%i',$userID))??[];
|
||||
if(!$oauthInfo){
|
||||
$tokenValidUntil = RootDB::db()->queryFirstField('SELECT token_valid_until from member where no=%i',$userID);
|
||||
|
||||
if(!$tokenValidUntil){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'초기화 가능한 로그인 상태가 아닙니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
$OTPValidUntil = $oauthInfo['OTPValidUntil']??null;
|
||||
|
||||
$now = TimeUtil::DatetimeNow();
|
||||
$expectedDate = TimeUtil::DatetimeFromNowDay(5);
|
||||
|
||||
if($expectedDate <= $OTPValidUntil){
|
||||
if($expectedDate <= $tokenValidUntil){
|
||||
Json::die([
|
||||
'result'=>false,
|
||||
'reason'=>'아직 연장 가능하지 않습니다.'
|
||||
]);
|
||||
}
|
||||
|
||||
unset($oauthInfo['OTPValidUntil']);
|
||||
unset($oauthInfo['tokenValidUntil']);
|
||||
RootDB::db()->update('member', [
|
||||
'oauth_info'=>Json::encode($oauthInfo)
|
||||
'token_valid_until'=> null
|
||||
], 'no=%i', $userID);
|
||||
|
||||
$session->logout();
|
||||
|
||||
Reference in New Issue
Block a user