🐛 fix: Prevent API abuse

This commit is contained in:
MartialBE 2024-03-30 19:49:49 +08:00
parent 89a84e2386
commit 988df5c13c
No known key found for this signature in database
GPG Key ID: F5A7AC860020C896
2 changed files with 15 additions and 1 deletions

14
middleware/prices.go Normal file
View File

@ -0,0 +1,14 @@
package middleware
import "github.com/gin-gonic/gin"
func PricesAuth() gin.HandlerFunc {
return func(c *gin.Context) {
typeParam := c.Query("type")
if typeParam == "old" {
AdminAuth()(c)
} else {
c.Next()
}
}
}

View File

@ -18,7 +18,7 @@ func SetApiRouter(router *gin.Engine) {
apiRouter.GET("/status", controller.GetStatus)
apiRouter.GET("/notice", controller.GetNotice)
apiRouter.GET("/about", controller.GetAbout)
apiRouter.GET("/prices", middleware.CORS(), controller.GetPricesList)
apiRouter.GET("/prices", middleware.PricesAuth(), middleware.CORS(), controller.GetPricesList)
apiRouter.GET("/ownedby", relay.GetModelOwnedBy)
apiRouter.GET("/home_page_content", controller.GetHomePageContent)
apiRouter.GET("/verification", middleware.CriticalRateLimit(), middleware.TurnstileCheck(), controller.SendEmailVerification)