mirror of
https://github.com/Rain-kl/OpenFlare.git
synced 2026-10-09 00:56:37 +08:00
[优化] POW 系统接口方案
This commit is contained in:
@@ -11,7 +11,10 @@ import (
|
||||
|
||||
// GetCapChallenge generates a new CAPTCHA challenge
|
||||
func GetCapChallenge(c *gin.Context) {
|
||||
scope := c.Query("scope")
|
||||
scope := c.Param("scope")
|
||||
if scope == "" {
|
||||
scope = c.Query("scope")
|
||||
}
|
||||
resp, err := service.CapManager.Generate(scope)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{
|
||||
@@ -25,7 +28,10 @@ func GetCapChallenge(c *gin.Context) {
|
||||
|
||||
// RedeemCapChallenge validates CAPTCHA solutions and yields a one-time redeem token
|
||||
func RedeemCapChallenge(c *gin.Context) {
|
||||
scope := c.Query("scope")
|
||||
scope := c.Param("scope")
|
||||
if scope == "" {
|
||||
scope = c.Query("scope")
|
||||
}
|
||||
|
||||
var req cap.RedeemRequest
|
||||
if !bind.JSON(c, &req) {
|
||||
|
||||
@@ -33,8 +33,8 @@ func SetApiRouter(router *gin.Engine) {
|
||||
|
||||
capRoute := apiRouter.Group("/cap")
|
||||
{
|
||||
capRoute.POST("/challenge", middleware.CriticalRateLimit(), controller.GetCapChallenge)
|
||||
capRoute.POST("/redeem", middleware.CriticalRateLimit(), controller.RedeemCapChallenge)
|
||||
capRoute.POST("/:scope/challenge", middleware.CriticalRateLimit(), controller.GetCapChallenge)
|
||||
capRoute.POST("/:scope/redeem", middleware.CriticalRateLimit(), controller.RedeemCapChallenge)
|
||||
}
|
||||
|
||||
userRoute := apiRouter.Group("/user")
|
||||
|
||||
@@ -160,7 +160,7 @@ export function LoginForm() {
|
||||
<div className="flex justify-center py-2">
|
||||
<cap-widget
|
||||
ref={capWidgetRef}
|
||||
data-cap-api-endpoint="/api/cap/"
|
||||
data-cap-api-endpoint="/api/cap/login/"
|
||||
onsolve={(e: CustomEvent<{ token: string }>) => {
|
||||
setCapToken(e.detail.token);
|
||||
}}
|
||||
|
||||
Reference in New Issue
Block a user