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")