From fc30a92ca4c1401cae260eda81a1fe60887c2c22 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sat, 26 Apr 2025 11:24:46 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=93=8D=E4=BD=9C=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B=E5=8F=8A=E9=83=A8=E5=88=86=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/tool.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/handler/tool.go b/handler/tool.go index 18015fd..d33dd1b 100644 --- a/handler/tool.go +++ b/handler/tool.go @@ -115,17 +115,18 @@ type QQCallbackReq struct { func GetQQAuthUrl(c *gin.Context) { //query uuid := c.Query("uuid") + hType := c.Query("type") var resp proto.GenerateResp - if uuid == "" { + if uuid == "" || hType == "" { resp.Code = proto.ParameterError - resp.Message = "uuid is empty" + resp.Message = "uuid or hType is empty" c.JSON(http.StatusOK, resp) return } params := url.Values{} params.Add("response_type", "code") params.Add("client_id", worker.AppId) - params.Add("state", "saw_"+uuid) + params.Add("state", "saw_"+hType+"_"+uuid) str := fmt.Sprintf("%s&redirect_uri=%s", params.Encode(), worker.RedirectURI) loginURL := fmt.Sprintf("%s?%s", "https://graph.qq.com/oauth2.0/authorize", str) //c.Redirect(http.StatusFound, loginURL) //重定向到QQ登录页面 @@ -644,17 +645,18 @@ func handleGithubCallback(c *gin.Context) { func ToGithubAuthPage(c *gin.Context) { uuid := c.Query("uuid") + hType := c.Query("type") //操作类型add,login var resp proto.GenerateResp - if uuid == "" { + if uuid == "" || hType == "" { resp.Code = proto.ParameterError - resp.Message = "uuid is empty" + resp.Message = "uuid or type is empty" c.JSON(http.StatusOK, resp) return } params := url.Values{} params.Add("client_id", proto.Config.GITHUB_CLIENT_ID) params.Add("login", uuid) - params.Add("state", "saw_"+uuid) + params.Add("state", "saw_"+hType+"_"+uuid) baseUri := "https://github.com/login/oauth/authorize" redirectUrl := fmt.Sprintf("%s?%s", baseUri, params.Encode()) redirectUrl = fmt.Sprintf("%s&redirect_uri=%s", redirectUrl, "https://sv.ljsea.top")