|
|
|
@ -19,8 +19,6 @@ import (
|
|
|
|
|
"idata/internal/service/user"
|
|
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
|
|
|
|
"github.com/jageros/hawox/errcode"
|
|
|
|
|
"github.com/jageros/hawox/httpx"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
func Registry(engine *gin.Engine) {
|
|
|
|
@ -32,20 +30,7 @@ func Registry(engine *gin.Engine) {
|
|
|
|
|
ur.GET("/secret", jwt.CheckToken, user.Secret)
|
|
|
|
|
ur.GET("/open", jwt.CheckToken, user.OpenApi)
|
|
|
|
|
|
|
|
|
|
apiR := r.Group("/api", auth)
|
|
|
|
|
apiR := r.Group("/api")
|
|
|
|
|
apiR.GET("/soup", soup.GetRandSoup)
|
|
|
|
|
apiR.GET("/almanac", almanac.Almanac)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func auth(ctx *gin.Context) {
|
|
|
|
|
uid, ok1 := httpx.DecodeUrlVal(ctx, "uid")
|
|
|
|
|
secret, ok2 := httpx.DecodeUrlVal(ctx, "secret")
|
|
|
|
|
if !ok1 || !ok2 {
|
|
|
|
|
httpx.ErrInterrupt(ctx, errcode.InvalidParam)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
if !user.Auth(uid, secret) {
|
|
|
|
|
httpx.ErrInterrupt(ctx, errcode.VerifyErr)
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|