From f694b0968dbacf551b29383a75aa989988a6e3e1 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Mon, 28 Apr 2025 18:31:21 +0800 Subject: [PATCH] =?UTF-8?q?gitee=E6=B5=8B=E8=AF=95=E5=9B=9E=E8=B0=83?= =?UTF-8?q?=E9=87=8D=E5=AE=9A=E5=90=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/tool.go | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/handler/tool.go b/handler/tool.go index f4945ab..1a86aff 100644 --- a/handler/tool.go +++ b/handler/tool.go @@ -677,19 +677,25 @@ func handleGiteeCallback(c *gin.Context) { if err != nil { fmt.Println("Decoding error:", err) } else { - decodedStr := string(decodedBytes) - //json解析 - var state proto.ThirdPartyLoginState - err = json.Unmarshal([]byte(decodedStr), &state) - log.Println("handle github callback state:", decodedStr, "\tcode:", code) - if err != nil { - log.Println("json unmarshal error:", err) + if code == "" || stateBase64Str == "" { + log.Println("code or state is empty") + } else { + decodedStr := string(decodedBytes) + //json解析 + var state proto.ThirdPartyLoginState + err = json.Unmarshal([]byte(decodedStr), &state) + if err != nil { + log.Println("json unmarshal error:", err) + } else { + log.Println("handle github callback state:", decodedStr, "\tcode:", code) + service.DoGiteeCallBack(&state, code) + } } - service.DoGiteeCallBack(&state, code) } resp.Code = 0 resp.Message = "success" c.JSON(http.StatusOK, resp) + c.Redirect(http.StatusFound, "https://sv.ljsea.top/") //重定向到登录页面 } func GetGithubAuthUrl(c *gin.Context) {