1
|
package middlewares
|
1
|
package middlewares
|
2
|
|
2
|
|
3
|
import (
|
3
|
import (
|
|
|
4
|
+ "strings"
|
|
|
5
|
+
|
4
|
"github.com/beego/beego/v2/server/web/context"
|
6
|
"github.com/beego/beego/v2/server/web/context"
|
5
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
|
7
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/constant"
|
6
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
8
|
"gitlab.fjmaimaimai.com/allied-creation/performance/pkg/domain"
|
|
@@ -8,7 +10,17 @@ import ( |
|
@@ -8,7 +10,17 @@ import ( |
8
|
|
10
|
|
9
|
func CheckFontToken() func(ctx *context.Context) {
|
11
|
func CheckFontToken() func(ctx *context.Context) {
|
10
|
return func(ctx *context.Context) {
|
12
|
return func(ctx *context.Context) {
|
11
|
- adminToken := ctx.Input.Header("x-font-token")
|
13
|
+ // adminToken := ctx.Input.Header("x-font-token")
|
|
|
14
|
+ // Bearer authorization_token
|
|
|
15
|
+ adminToken := ctx.Input.Header("Authorization")
|
|
|
16
|
+ //以一个空格" ",做切分
|
|
|
17
|
+ strList := strings.Split(adminToken, " ")
|
|
|
18
|
+ if len(strList) > 1 {
|
|
|
19
|
+ adminToken = strList[1]
|
|
|
20
|
+ }
|
|
|
21
|
+ if len(strList) == 1 {
|
|
|
22
|
+ adminToken = strList[0]
|
|
|
23
|
+ }
|
12
|
userAuth, err := (&domain.UserAuth{}).ParseAccessToken(adminToken)
|
24
|
userAuth, err := (&domain.UserAuth{}).ParseAccessToken(adminToken)
|
13
|
if err != nil || userAuth.UserId <= 0 {
|
25
|
if err != nil || userAuth.UserId <= 0 {
|
14
|
forbidden(ctx)
|
26
|
forbidden(ctx)
|