作者 陈志颖

fix:过滤路由

... ... @@ -6,6 +6,7 @@ import (
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/constant"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/infrastructure/utils"
"gitlab.fjmaimaimai.com/mmm-go/partner/pkg/protocol"
"net/url"
"strconv"
"strings"
)
... ... @@ -16,6 +17,19 @@ func CheckJWTToken(ctx *context.Context) {
msg *protocol.ResponseMessage
)
// 需要被过滤的地址 一定要写键值
filterMap := map[string]string{
"/v1/auth/checkPassword": "校验密码",
}
urlStr := ""
tmpUrl, err := url.Parse(ctx.Request.RequestURI)
if err == nil {
urlStr = tmpUrl.Path
}
if res := filterMap[urlStr]; res == "" {
/** 不在 Map 内对请求进行处理 **/
token := ctx.Input.Header("x-mmm-accesstoken")
if strings.HasSuffix(ctx.Request.RequestURI, "login") ||
... ... @@ -57,5 +71,6 @@ func CheckJWTToken(ctx *context.Context) {
}
}
}
}
return
}
... ...
... ... @@ -6,10 +6,9 @@ import (
)
func init() {
beego.Router("/auth/checkPassword", &controllers.AuthController{}, "Post:CheckPassword")
nsV1 := beego.NewNamespace("v1") //, beego.NSBefore(middleware.CheckJWTToken)
nsV1.Router("/auth/login", &controllers.AuthController{}, "Post:Login")
//nsV1.Router("/auth/checkPassword", &controllers.AuthController{}, "Post:CheckPassword") // 校验密码
nsV1.Router("/auth/checkPassword", &controllers.AuthController{}, "Post:CheckPassword") // 校验密码
nsV1.Router("/auth/smsCode", &controllers.AuthController{}, "Post:SmsCode")
nsV1.Router("/auth/accessToken", &controllers.AuthController{}, "Post:AccessToken")
nsV1.Router("/auth/refreshToken", &controllers.AuthController{}, "Post:RefreshToken")
... ...