正在显示
2 个修改的文件
包含
6 行增加
和
1 行删除
@@ -15,7 +15,9 @@ func CheckJWTToken(ctx *context.Context) { | @@ -15,7 +15,9 @@ func CheckJWTToken(ctx *context.Context) { | ||
15 | var ( | 15 | var ( |
16 | msg *protocol.ResponseMessage | 16 | msg *protocol.ResponseMessage |
17 | ) | 17 | ) |
18 | + | ||
18 | token := ctx.Input.Header("x-mmm-accesstoken") | 19 | token := ctx.Input.Header("x-mmm-accesstoken") |
20 | + | ||
19 | if strings.HasSuffix(ctx.Request.RequestURI, "login") || | 21 | if strings.HasSuffix(ctx.Request.RequestURI, "login") || |
20 | strings.HasSuffix(ctx.Request.RequestURI, "accessToken") || | 22 | strings.HasSuffix(ctx.Request.RequestURI, "accessToken") || |
21 | strings.HasSuffix(ctx.Request.RequestURI, "refreshToken") || | 23 | strings.HasSuffix(ctx.Request.RequestURI, "refreshToken") || |
@@ -29,11 +31,13 @@ func CheckJWTToken(ctx *context.Context) { | @@ -29,11 +31,13 @@ func CheckJWTToken(ctx *context.Context) { | ||
29 | strings.HasSuffix(ctx.Request.RequestURI, "changePassword") { | 31 | strings.HasSuffix(ctx.Request.RequestURI, "changePassword") { |
30 | return | 32 | return |
31 | } | 33 | } |
34 | + | ||
32 | defer func() { | 35 | defer func() { |
33 | if msg != nil { | 36 | if msg != nil { |
34 | ctx.Output.JSON(msg, false, false) | 37 | ctx.Output.JSON(msg, false, false) |
35 | } | 38 | } |
36 | }() | 39 | }() |
40 | + | ||
37 | if u, err := utils.ParseJWTToken(token); err != nil { | 41 | if u, err := utils.ParseJWTToken(token); err != nil { |
38 | msg = protocol.NewMesage(4141) | 42 | msg = protocol.NewMesage(4141) |
39 | return | 43 | return |
@@ -6,9 +6,10 @@ import ( | @@ -6,9 +6,10 @@ import ( | ||
6 | ) | 6 | ) |
7 | 7 | ||
8 | func init() { | 8 | func init() { |
9 | + beego.Router("/auth/checkPassword", &controllers.AuthController{}, "Post:CheckPassword") | ||
9 | nsV1 := beego.NewNamespace("v1") //, beego.NSBefore(middleware.CheckJWTToken) | 10 | nsV1 := beego.NewNamespace("v1") //, beego.NSBefore(middleware.CheckJWTToken) |
10 | nsV1.Router("/auth/login", &controllers.AuthController{}, "Post:Login") | 11 | nsV1.Router("/auth/login", &controllers.AuthController{}, "Post:Login") |
11 | - nsV1.Router("/auth/checkPassword", &controllers.AuthController{}, "Post:CheckPassword") // 校验密码 | 12 | + //nsV1.Router("/auth/checkPassword", &controllers.AuthController{}, "Post:CheckPassword") // 校验密码 |
12 | nsV1.Router("/auth/smsCode", &controllers.AuthController{}, "Post:SmsCode") | 13 | nsV1.Router("/auth/smsCode", &controllers.AuthController{}, "Post:SmsCode") |
13 | nsV1.Router("/auth/accessToken", &controllers.AuthController{}, "Post:AccessToken") | 14 | nsV1.Router("/auth/accessToken", &controllers.AuthController{}, "Post:AccessToken") |
14 | nsV1.Router("/auth/refreshToken", &controllers.AuthController{}, "Post:RefreshToken") | 15 | nsV1.Router("/auth/refreshToken", &controllers.AuthController{}, "Post:RefreshToken") |
-
请 注册 或 登录 后发表评论