diff --git a/core/maingate.go b/core/maingate.go index 7131a91..d55b2e3 100644 --- a/core/maingate.go +++ b/core/maingate.go @@ -587,6 +587,7 @@ func (mg *Maingate) setUserToken(info usertokeninfo) error { "lastupdate": time.Now().Unix(), "accesstoken": info.accesstoken, "accesstoken_expire_time": info.accesstoken_expire_time, + "email": info.email, }, }, options.Update().SetUpsert(true)) return logger.ErrorWithCallStack(err) @@ -639,6 +640,11 @@ func (mg *Maingate) getUserTokenWithCheck(platform string, userid string, brinfo info.accesstoken_expire_time = accesstoken_expire_time.(int64) } + email := found["email"] + if email != nil { + info.email = email.(string) + } + return info, nil } @@ -676,6 +682,10 @@ func (mg *Maingate) updateUserinfo(info usertokeninfo) (bool, string, string) { return false, "", "" } + if !(strings.HasPrefix("email", "__dummy_") && strings.HasSuffix("email", "temp__")) { + info.email = email + } + mg.setUserToken(info) return success, userid, email diff --git a/core/platformapple.go b/core/platformapple.go index dc9daa9..c8a0370 100644 --- a/core/platformapple.go +++ b/core/platformapple.go @@ -255,6 +255,7 @@ func (mg *Maingate) platform_apple_authorize_result(w http.ResponseWriter, r *ht info.userid = userid info.token = resp.RefreshToken info.brinfo = brinfo + info.email = email mg.setUserToken(info) params := url.Values{} diff --git a/core/platformfirebaseauth.go b/core/platformfirebaseauth.go index 5741818..abc2d46 100644 --- a/core/platformfirebaseauth.go +++ b/core/platformfirebaseauth.go @@ -208,6 +208,7 @@ func (mg *Maingate) platform_firebaseauth_authorize_raw(w http.ResponseWriter, b info.brinfo = brinfo info.accesstoken = "" info.accesstoken_expire_time = acceestoken_expire_time + info.email = email mg.setUserToken(info) mg.mongoClient.Delete(CollectionFirebaseUserInfo, bson.M{ diff --git a/core/platformgoogle.go b/core/platformgoogle.go index 10d6013..3a58f5a 100644 --- a/core/platformgoogle.go +++ b/core/platformgoogle.go @@ -262,6 +262,7 @@ func (mg *Maingate) platform_google_authorize_result(w http.ResponseWriter, r *h info.brinfo = brinfo info.accesstoken = respReferesh.AccessToken info.accesstoken_expire_time = acceestoken_expire_time + info.email = email mg.setUserToken(info) params := url.Values{} @@ -316,6 +317,7 @@ func (mg *Maingate) platform_google_getuserinfo(info usertokeninfo) (bool, strin info.token = respReferesh.RefreshToken info.accesstoken = respReferesh.AccessToken info.accesstoken_expire_time = acceestoken_expire_time + info.email = email mg.setUserToken(info) //-- accesstoken 업데이트 } else { logger.Println("JWTparseCode fail.") diff --git a/core/platformmicrosoft.go b/core/platformmicrosoft.go index 3375905..b444692 100644 --- a/core/platformmicrosoft.go +++ b/core/platformmicrosoft.go @@ -239,6 +239,7 @@ func (mg *Maingate) platform_microsoft_authorize_result(w http.ResponseWriter, r info.brinfo = brinfo info.accesstoken = respReferesh.AccessToken info.accesstoken_expire_time = acceestoken_expire_time + info.email = "" mg.setUserToken(info) params := url.Values{} @@ -295,6 +296,7 @@ func (mg *Maingate) platform_microsoft_getuserinfo(info usertokeninfo) (bool, st info.token = respReferesh.RefreshToken info.accesstoken = respReferesh.AccessToken info.accesstoken_expire_time = acceestoken_expire_time + info.email = "" mg.setUserToken(info) //-- accesstoken 업데이트 } else { logger.Println("JWTparseCode fail.") diff --git a/core/platformsteam.go b/core/platformsteam.go index bcdd229..4c3b602 100644 --- a/core/platformsteam.go +++ b/core/platformsteam.go @@ -53,6 +53,7 @@ func (mg *Maingate) platform_steamsdk_authorize(w http.ResponseWriter, r *http.R info.brinfo = brinfo //info.accesstoken = respReferesh.AccessToken info.accesstoken_expire_time = acceestoken_expire_time + info.email = "" mg.setUserToken(info) params := url.Values{} diff --git a/core/platformtwitter.go b/core/platformtwitter.go index 58396c5..a10017a 100644 --- a/core/platformtwitter.go +++ b/core/platformtwitter.go @@ -208,6 +208,7 @@ func (mg *Maingate) platform_twitter_authorize_result(w http.ResponseWriter, r * info.token = token info.secret = secret info.brinfo = brinfo + info.email = "" mg.setUserToken(info) params := url.Values{} diff --git a/core/service.go b/core/service.go index 1389d95..e0b911a 100644 --- a/core/service.go +++ b/core/service.go @@ -63,6 +63,7 @@ type usertokeninfo struct { token string //refreshtoken secret string brinfo string + email string accesstoken string // microsoft only accesstoken_expire_time int64 // microsoft only }