gitee测试回调重定向

This commit is contained in:
junleea 2025-04-28 18:31:21 +08:00
parent aab8b65f99
commit f694b0968d
1 changed files with 14 additions and 8 deletions

View File

@ -677,19 +677,25 @@ func handleGiteeCallback(c *gin.Context) {
if err != nil { if err != nil {
fmt.Println("Decoding error:", err) fmt.Println("Decoding error:", err)
} else { } else {
decodedStr := string(decodedBytes) if code == "" || stateBase64Str == "" {
//json解析 log.Println("code or state is empty")
var state proto.ThirdPartyLoginState } else {
err = json.Unmarshal([]byte(decodedStr), &state) decodedStr := string(decodedBytes)
log.Println("handle github callback state:", decodedStr, "\tcode:", code) //json解析
if err != nil { var state proto.ThirdPartyLoginState
log.Println("json unmarshal error:", err) 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.Code = 0
resp.Message = "success" resp.Message = "success"
c.JSON(http.StatusOK, resp) c.JSON(http.StatusOK, resp)
c.Redirect(http.StatusFound, "https://sv.ljsea.top/") //重定向到登录页面
} }
func GetGithubAuthUrl(c *gin.Context) { func GetGithubAuthUrl(c *gin.Context) {