From f380b1542d10e1263af809f3d4bbb6add2f96b51 Mon Sep 17 00:00:00 2001 From: Antonio Date: Fri, 7 Jul 2023 15:17:02 +0800 Subject: [PATCH] download images on fail --- cmd/api/main.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmd/api/main.go b/cmd/api/main.go index 5e59208..818d915 100644 --- a/cmd/api/main.go +++ b/cmd/api/main.go @@ -50,9 +50,15 @@ func captchaStart(c *gin.Context) { err = session.SubmitAnswer(2) if err == nil { c.JSON(200, gin.H{"token": token, "status": "success"}) + return } log.Println("Retrying...") + } + // Download the images + images, err = funcaptcha.DownloadChallenge(session.ConciseChallenge.URLs, true) + if err != nil { + c.JSON(500, gin.H{"error": "failed to download images"}) } c.JSON(http.StatusNetworkAuthenticationRequired, gin.H{"token": token, "session": session, "status": "captcha", "images": images}) }