...
|
...
|
@@ -2,14 +2,15 @@ package middleware |
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
log1 "log"
|
|
|
"net/http"
|
|
|
"net/url"
|
|
|
|
|
|
"github.com/beego/beego/v2/server/web"
|
|
|
"github.com/beego/beego/v2/server/web/context"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/domain"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/infrastructure/cache"
|
|
|
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-gateway/pkg/log"
|
|
|
log1 "log"
|
|
|
"net/http"
|
|
|
"net/url"
|
|
|
)
|
|
|
|
|
|
type CtxKeyLoginToken struct{}
|
...
|
...
|
@@ -64,7 +65,7 @@ func CheckAccessToken(next web.FilterFunc) web.FilterFunc { |
|
|
return
|
|
|
}
|
|
|
platform := domain.ParsePlatform(ctx.Input.Header("x-mmm-devicetype"))
|
|
|
//redis缓存
|
|
|
// redis缓存
|
|
|
tokenCache := cache.LoginTokenCache{}
|
|
|
token, err := tokenCache.GetAccessToken(tk.Account, platform)
|
|
|
if err != nil {
|
...
|
...
|
@@ -137,19 +138,19 @@ func CheckAccessToken2() web.FilterFunc { |
|
|
log.Logger.Error(err.Error())
|
|
|
return
|
|
|
}
|
|
|
platform := domain.ParsePlatform(ctx.Input.Header("x-mmm-devicetype"))
|
|
|
//redis缓存
|
|
|
tokenCache := cache.LoginTokenCache{}
|
|
|
token, err := tokenCache.GetAccessToken(tk.Account, platform)
|
|
|
if err != nil {
|
|
|
log.Logger.Error(err.Error())
|
|
|
return
|
|
|
}
|
|
|
if token != tokenStr {
|
|
|
log1.Println("token not equal \n" + tk.Account + "\n" + tokenStr + "\n" + token)
|
|
|
err = fmt.Errorf("access token not exists")
|
|
|
return
|
|
|
}
|
|
|
// platform := domain.ParsePlatform(ctx.Input.Header("x-mmm-devicetype"))
|
|
|
// //redis缓存
|
|
|
// tokenCache := cache.LoginTokenCache{}
|
|
|
// token, err := tokenCache.GetAccessToken(tk.Account, platform)
|
|
|
// if err != nil {
|
|
|
// log.Logger.Error(err.Error())
|
|
|
// return
|
|
|
// }
|
|
|
// if token != tokenStr {
|
|
|
// log1.Println("token not equal \n" + tk.Account + "\n" + tokenStr + "\n" + token)
|
|
|
// err = fmt.Errorf("access token not exists")
|
|
|
// return
|
|
|
// }
|
|
|
ctx.Input.SetData(CtxKeyLoginToken{}, tk)
|
|
|
}
|
|
|
} |
...
|
...
|
|