머지
This commit is contained in:
@@ -25,7 +25,7 @@ class User_Management_Path
|
||||
public static $SIGNUP = "/v1/user/signup";
|
||||
public static $UNLINK = "/v1/user/unlink";
|
||||
public static $LOGOUT = "/v1/user/logout";
|
||||
public static $ME = "/v1/user/me";
|
||||
public static $ME = "/v2/user/me";
|
||||
public static $UPDATE_PROFILE = "/v1/user/update_profile";
|
||||
public static $USER_IDS = "/v1/user/ids";
|
||||
}
|
||||
@@ -97,12 +97,12 @@ class Kakao_REST_API_Helper
|
||||
$requestUrl .= '?'.$params;
|
||||
}
|
||||
|
||||
$opts = array(
|
||||
CURLOPT_URL => $requestUrl,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_SSLVERSION => 1,
|
||||
);
|
||||
$opts = [
|
||||
CURLOPT_URL => $requestUrl,
|
||||
CURLOPT_RETURNTRANSFER => true,
|
||||
CURLOPT_SSL_VERIFYPEER => false,
|
||||
CURLOPT_SSLVERSION => CURL_SSLVERSION_TLSv1,
|
||||
];
|
||||
|
||||
if ($api_path != '/oauth/token') {
|
||||
if (in_array($api_path, self::$admin_apis)) {
|
||||
@@ -182,8 +182,7 @@ class Kakao_REST_API_Helper
|
||||
$params = [
|
||||
'grant_type'=>'refresh_token',
|
||||
'client_id'=>$this->REST_KEY,
|
||||
'redirect_uri'=>$this->REDIRECT_URI,
|
||||
'code'=>$refresh_token
|
||||
'refresh_token'=>$refresh_token
|
||||
];
|
||||
$result = $this->_create_or_refresh_access_token($params);
|
||||
|
||||
@@ -213,8 +212,12 @@ class Kakao_REST_API_Helper
|
||||
public function meWithEmail()
|
||||
{
|
||||
$params = [
|
||||
'propertyKeys'=>'["id","kaacount_email","kaccount_email_verified"]'
|
||||
];
|
||||
'property_keys'=>'['.
|
||||
'"id",'.
|
||||
'"kakao_account.has_email","kakao_account.email",'.
|
||||
'"kakao_account.is_email_valid","kakao_account.is_email_verified"'.
|
||||
']'
|
||||
];
|
||||
return $this->request(User_Management_Path::$ME);
|
||||
}
|
||||
|
||||
|
||||
+27
-3
@@ -8,12 +8,15 @@ namespace sammo;
|
||||
* @property string $userName 유저명
|
||||
* @property int $userGrade 유저등급
|
||||
* @property string $ip IP
|
||||
* @property bool $reqOTP 인증 코드 필요
|
||||
* @property array $acl 권한
|
||||
* @property string $tokenValidUntil 로그인 토큰 길이
|
||||
*/
|
||||
class Session
|
||||
{
|
||||
const PROTECTED_NAMES = [
|
||||
'ip'=>true,
|
||||
'reqOTP'=>true,
|
||||
'time'=>true,
|
||||
'userID'=>true,
|
||||
'userName'=>true,
|
||||
@@ -21,6 +24,7 @@ class Session
|
||||
'writeClosed'=>true,
|
||||
'generalID'=>true,
|
||||
'generalName'=>true,
|
||||
'tokenValidUntil'=>true,
|
||||
'acl'=>true
|
||||
];
|
||||
|
||||
@@ -163,7 +167,7 @@ class Session
|
||||
return Util::array_get($_SESSION[$name]);
|
||||
}
|
||||
|
||||
public function login(int $userID, string $userName, int $grade, array $acl): Session
|
||||
public function login(int $userID, string $userName, int $grade, bool $reqOTP, ?string $tokenValidUntil, array $acl): Session
|
||||
{
|
||||
$this->set('userID', $userID);
|
||||
$this->set('userName', $userName);
|
||||
@@ -171,10 +175,16 @@ class Session
|
||||
$this->set('time', time());
|
||||
$this->set('userGrade', $grade);
|
||||
$this->set('acl', $acl);
|
||||
$this->set('access_token', null);
|
||||
$this->set('reqOTP', $reqOTP);
|
||||
$this->set('tokenValidUntil', $tokenValidUntil);
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setReqOTP(bool $reqOTP=false, string $tokenValidUntil){
|
||||
$this->set('reqOTP', $reqOTP);
|
||||
$this->set('tokenValidUntil', $tokenValidUntil);
|
||||
}
|
||||
|
||||
|
||||
public function logout(): Session
|
||||
{
|
||||
@@ -189,6 +199,7 @@ class Session
|
||||
$this->set('userName', null);
|
||||
$this->set('userGrade', null);
|
||||
$this->set('acl', null);
|
||||
$this->set('reqOTP', null);
|
||||
$this->set('time', time());
|
||||
return $this;
|
||||
}
|
||||
@@ -324,8 +335,21 @@ class Session
|
||||
return $obj->userID;
|
||||
}
|
||||
|
||||
public function isLoggedIn(): bool
|
||||
public function isLoggedIn(bool $ignoreOTP = false): bool
|
||||
{
|
||||
if(!$ignoreOTP){
|
||||
if($this->reqOTP){
|
||||
return false;
|
||||
}
|
||||
if(!$this->tokenValidUntil){
|
||||
return false;
|
||||
}
|
||||
$now = TimeUtil::DatetimeNow();
|
||||
if($this->tokenValidUntil < $now){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($this->userID) {
|
||||
return true;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user