作者 yangfu

修改:jwt过滤修改

@@ -11,4 +11,7 @@ func init() { @@ -11,4 +11,7 @@ func init() {
11 beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequestBodyFilter()) 11 beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequestBodyFilter())
12 beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequstLogFilter(Logger)) 12 beego.InsertFilter("/*", beego.BeforeExec, middleware.CreateRequstLogFilter(Logger))
13 beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(Logger), false) 13 beego.InsertFilter("/*", beego.AfterExec, middleware.CreateResponseLogFilter(Logger), false)
  14 +
  15 + beego.InsertFilter("/v1", beego.BeforeExec, middleware.CheckJWTToken)
  16 + beego.InsertFilter("/v2", beego.BeforeExec, middleware.CheckJWTToken)
14 } 17 }
@@ -3,11 +3,10 @@ package routers @@ -3,11 +3,10 @@ package routers
3 import ( 3 import (
4 "github.com/astaxie/beego" 4 "github.com/astaxie/beego"
5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/controllers" 5 "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/controllers"
6 - "gitlab.fjmaimaimai.com/mmm-go/partner/pkg/port/appsvr/middleware"  
7 ) 6 )
8 7
9 func init() { 8 func init() {
10 - nsV1 := beego.NewNamespace("v1", beego.NSBefore(middleware.CheckJWTToken)) //beego.NSNamespace("auth", beego.NSInclude(&controllers.AuthController{})) 9 + nsV1 := beego.NewNamespace("v1") //, beego.NSBefore(middleware.CheckJWTToken)
11 nsV1.Router("/auth/login", &controllers.AuthController{}, "Post:Login") 10 nsV1.Router("/auth/login", &controllers.AuthController{}, "Post:Login")
12 nsV1.Router("/auth/smsCode", &controllers.AuthController{}, "Post:SmsCode") 11 nsV1.Router("/auth/smsCode", &controllers.AuthController{}, "Post:SmsCode")
13 nsV1.Router("/auth/accessToken", &controllers.AuthController{}, "Post:AccessToken") 12 nsV1.Router("/auth/accessToken", &controllers.AuthController{}, "Post:AccessToken")
@@ -43,7 +42,7 @@ func init() { @@ -43,7 +42,7 @@ func init() {
43 } 42 }
44 43
45 func InitV2() { 44 func InitV2() {
46 - nsV2 := beego.NewNamespace("v2", beego.NSBefore(middleware.CheckJWTToken)) // , 45 + nsV2 := beego.NewNamespace("v2") // ,, beego.NSBefore(middleware.CheckJWTToken)
47 nsV2.Router("/auth/login", &controllers.AuthController{}, "Post:LoginV2") 46 nsV2.Router("/auth/login", &controllers.AuthController{}, "Post:LoginV2")
48 nsV2.Router("/user/userInfo", &controllers.UserController{}, "Post:UserInfoV2") 47 nsV2.Router("/user/userInfo", &controllers.UserController{}, "Post:UserInfoV2")
49 beego.AddNamespace(nsV2) 48 beego.AddNamespace(nsV2)