Hybe로그인 관련 제재 로그인 금지 처리 - 로그인 authorize에서 제재 처리 하는 기능 추가
This commit is contained in:
@ -25,11 +25,20 @@ type HybeImSDKLoginAuthInfo struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Hiveim_LoginVerifyResult struct {
|
type Hiveim_LoginVerifyResult struct {
|
||||||
State string `json:"state"`
|
State string `json:"state"`
|
||||||
ImId string `json:"imId"`
|
ImId string `json:"imId"`
|
||||||
Provider string `json:"provider"`
|
Provider string `json:"provider"`
|
||||||
Os string `json:"os"`
|
Os string `json:"os"`
|
||||||
AppStore string `json:"appStore"`
|
AppStore string `json:"appStore"`
|
||||||
|
UserBlockInfo []Hiveim_UserBlockInfo `json:"blocks"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type Hiveim_UserBlockInfo struct {
|
||||||
|
BlockId int `json:"blockId"`
|
||||||
|
ReasonId int `json:"reasonId"`
|
||||||
|
BlockedAt int64 `json:"blockedAt"`
|
||||||
|
ExpireAt int64 `json:"expireAt"`
|
||||||
|
Permanent bool `json:"permanent"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Hiveim_LoginValidationResponse struct {
|
type Hiveim_LoginValidationResponse struct {
|
||||||
@ -56,7 +65,22 @@ func (mg *Maingate) platform_hybeim_authorize(w http.ResponseWriter, r *http.Req
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = authenticateHybeImUser(config.HybeImProjectIdstring, config.HybeImServiceIdstring, config.HybeImAccessKey, config.HybeImEndPoint, authinfo.UserHybeimid, authinfo.UserLoginVerifyToken); err == nil {
|
var resultcode string
|
||||||
|
var blockinfo Hiveim_UserBlockInfo
|
||||||
|
if !*noauth {
|
||||||
|
err, resultcode, blockinfo = authenticateHybeImUser(config.HybeImProjectIdstring, config.HybeImServiceIdstring, config.HybeImAccessKey, config.HybeImEndPoint, authinfo.UserHybeimid, authinfo.UserLoginVerifyToken)
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://hybeim.gitbook.io/im-assemble/api/im-assemble-s2s-api#login-verify
|
||||||
|
// SUCCESS : 성공
|
||||||
|
// INVALID_LOGIN_VERIFY_TOKEN : login 인증 토큰 오류
|
||||||
|
// LOGIN_VERIFY_EXPIRED : login 인증 토큰 만료
|
||||||
|
// INVALID_SERVICE_ID : 유효 하지 않은 서비스 id
|
||||||
|
// WITHDRAWAL_ACCOUNT : 탈퇴 대기 상태 유저
|
||||||
|
// RELOGIN_REQUIRED : 로그인 데이터에 문제가 있어 다시 로그인 해야 되는 경우
|
||||||
|
// INTERNAL_SERVER_ERROR : 서버 오류
|
||||||
|
|
||||||
|
if err == nil && resultcode == "SUCCESS" {
|
||||||
acceestoken_expire_time := time.Date(2999, 1, int(time.January), 0, 0, 0, 0, time.UTC).Unix()
|
acceestoken_expire_time := time.Date(2999, 1, int(time.January), 0, 0, 0, 0, time.UTC).Unix()
|
||||||
|
|
||||||
var info usertokeninfo
|
var info usertokeninfo
|
||||||
@ -73,14 +97,25 @@ func (mg *Maingate) platform_hybeim_authorize(w http.ResponseWriter, r *http.Req
|
|||||||
params.Add("authtype", AuthPlatformHybeim)
|
params.Add("authtype", AuthPlatformHybeim)
|
||||||
w.Write([]byte("?" + params.Encode()))
|
w.Write([]byte("?" + params.Encode()))
|
||||||
//http.Redirect(w, r, "actionsquare://login?"+Result, http.StatusSeeOther)
|
//http.Redirect(w, r, "actionsquare://login?"+Result, http.StatusSeeOther)
|
||||||
|
return
|
||||||
} else {
|
} else {
|
||||||
logger.Println(err)
|
params := url.Values{}
|
||||||
http.Redirect(w, r, "actionsquare://error", http.StatusSeeOther)
|
params.Add("resultcode", resultcode)
|
||||||
|
if resultcode == "BLOCKED" {
|
||||||
|
blockinfoBytes, _ := json.Marshal(blockinfo)
|
||||||
|
blockinfostr := string(blockinfoBytes)
|
||||||
|
params.Add("blockinfo", blockinfostr)
|
||||||
|
}
|
||||||
|
w.WriteHeader(http.StatusUnauthorized)
|
||||||
|
w.Write([]byte("?" + params.Encode()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// logger.Println(err)
|
||||||
|
// http.Redirect(w, r, "actionsquare://error", http.StatusSeeOther)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func authenticateHybeImUser(projectid, serviceid, accesskey, endpoint, imid, UserLoginVerifyToken string) error {
|
func authenticateHybeImUser(projectid, serviceid, accesskey, endpoint, imid, UserLoginVerifyToken string) (error, string, Hiveim_UserBlockInfo) {
|
||||||
|
|
||||||
// endpoint
|
// endpoint
|
||||||
// qa = https://api-qa.pub-dev.hybegames.io
|
// qa = https://api-qa.pub-dev.hybegames.io
|
||||||
@ -118,9 +153,10 @@ func authenticateHybeImUser(projectid, serviceid, accesskey, endpoint, imid, Use
|
|||||||
resp.Body.Close()
|
resp.Body.Close()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
var blockinfo Hiveim_UserBlockInfo
|
||||||
body, e := ioutil.ReadAll(resp.Body)
|
body, e := ioutil.ReadAll(resp.Body)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
return e
|
return e, "", blockinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
json.Unmarshal(body, &respReferesh)
|
json.Unmarshal(body, &respReferesh)
|
||||||
@ -129,26 +165,29 @@ func authenticateHybeImUser(projectid, serviceid, accesskey, endpoint, imid, Use
|
|||||||
|
|
||||||
var doc map[string]interface{}
|
var doc map[string]interface{}
|
||||||
if err := json.Unmarshal(body, &doc); err != nil {
|
if err := json.Unmarshal(body, &doc); err != nil {
|
||||||
return err
|
return err, respReferesh.ResultCode, blockinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
if respReferesh.ResultCode != "SUCCESS" {
|
// if respReferesh.ResultData.State != "NORMAL" {
|
||||||
return errors.New("higveimSDK: ResultCode is not SUCCESS")
|
// return errors.New("higveimSDK: State is not NORMAL"), respReferesh.ResultCode, blockinfo
|
||||||
}
|
// }
|
||||||
|
|
||||||
if respReferesh.ResultData.State != "NORMAL" {
|
|
||||||
return errors.New("higveimSDK: State is not NORMAL")
|
|
||||||
}
|
|
||||||
|
|
||||||
if respReferesh.ResultData.Provider != "STEAM" {
|
if respReferesh.ResultData.Provider != "STEAM" {
|
||||||
return errors.New("higveimSDK: Provider is not STEAM")
|
return errors.New("higveimSDK: Provider is not STEAM"), respReferesh.ResultCode, blockinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
if respReferesh.ResultData.ImId != imid {
|
if respReferesh.ResultData.ImId != imid {
|
||||||
return errors.New("higveimSDK: ImId is not match")
|
return errors.New("higveimSDK: ImId is not match"), respReferesh.ResultCode, blockinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
return nil
|
if respReferesh.ResultCode == "SUCCESS" {
|
||||||
|
if respReferesh.ResultData.State == "BLOCKED" && len(respReferesh.ResultData.UserBlockInfo) > 0 {
|
||||||
|
blockinfo = respReferesh.ResultData.UserBlockInfo[0]
|
||||||
|
return nil, "BLOCKED", blockinfo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil, respReferesh.ResultCode, blockinfo
|
||||||
}
|
}
|
||||||
|
|
||||||
func (mg *Maingate) platform_hybeim_getuserinfo(info usertokeninfo) (bool, string, string) {
|
func (mg *Maingate) platform_hybeim_getuserinfo(info usertokeninfo) (bool, string, string) {
|
||||||
|
|||||||
Reference in New Issue
Block a user