正在显示
5 个修改的文件
包含
17 行增加
和
5 行删除
@@ -9,6 +9,7 @@ HTTP_PORT = 8081 | @@ -9,6 +9,7 @@ HTTP_PORT = 8081 | ||
9 | ENABLE_KAFKA_LOG11 = true | 9 | ENABLE_KAFKA_LOG11 = true |
10 | HTTPS_PORT = 8143 | 10 | HTTPS_PORT = 8143 |
11 | ALLIED_CREATION_USER_HOST = http://allied-creation-user-dev.fjmaimaimai.com | 11 | ALLIED_CREATION_USER_HOST = http://allied-creation-user-dev.fjmaimaimai.com |
12 | +# AUTH_SERVER_HOST = http://127.0.0.1:8081 | ||
12 | BYTE_CORE_HOST = http://47.97.5.102:8303 | 13 | BYTE_CORE_HOST = http://47.97.5.102:8303 |
13 | METADATA_BASTION_HOST = http://106.75.231.90:9999 | 14 | METADATA_BASTION_HOST = http://106.75.231.90:9999 |
14 | 15 |
@@ -24,7 +24,7 @@ var METADATA_BASTION_HOST = "http://127.0.0.1:8080" | @@ -24,7 +24,7 @@ var METADATA_BASTION_HOST = "http://127.0.0.1:8080" | ||
24 | 24 | ||
25 | var BYTE_CORE_HOST = "http://192.168.100.34:8303" | 25 | var BYTE_CORE_HOST = "http://192.168.100.34:8303" |
26 | 26 | ||
27 | -var AUTH_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com/" | 27 | +var AUTH_SERVER_HOST = "http://digital-platform-dev.fjmaimaimai.com" |
28 | 28 | ||
29 | //var CUSTOMER_ACCOUNT = []int64{3129687560814592, 3129687690100739, 3492238958608384} | 29 | //var CUSTOMER_ACCOUNT = []int64{3129687560814592, 3129687690100739, 3492238958608384} |
30 | 30 | ||
@@ -45,6 +45,7 @@ func init() { | @@ -45,6 +45,7 @@ func init() { | ||
45 | BYTE_CORE_HOST = Configurator.DefaultString("BYTE_CORE_HOST", BYTE_CORE_HOST) | 45 | BYTE_CORE_HOST = Configurator.DefaultString("BYTE_CORE_HOST", BYTE_CORE_HOST) |
46 | SERVICE_ENV = Configurator.DefaultString("SERVICE_ENV", SERVICE_ENV) | 46 | SERVICE_ENV = Configurator.DefaultString("SERVICE_ENV", SERVICE_ENV) |
47 | HTTP_PORT = Configurator.DefaultInt("HTTP_PORT", HTTP_PORT) | 47 | HTTP_PORT = Configurator.DefaultInt("HTTP_PORT", HTTP_PORT) |
48 | + AUTH_SERVER_HOST = Configurator.DefaultString("AUTH_SERVER_HOST", AUTH_SERVER_HOST) | ||
48 | SERVICE_NAME = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV) | 49 | SERVICE_NAME = fmt.Sprintf("%v-%v", SERVICE_NAME, SERVICE_ENV) |
49 | PPROF_ON = Configurator.DefaultBool("PPROF_ON", PPROF_ON) | 50 | PPROF_ON = Configurator.DefaultBool("PPROF_ON", PPROF_ON) |
50 | CACHE_PREFIX = SERVICE_NAME + ":" + SERVICE_ENV | 51 | CACHE_PREFIX = SERVICE_NAME + ":" + SERVICE_ENV |
@@ -39,3 +39,8 @@ func (tk *UserToken) ParseToken(str string) error { | @@ -39,3 +39,8 @@ func (tk *UserToken) ParseToken(str string) error { | ||
39 | } | 39 | } |
40 | return errors.New("token 解析失败") | 40 | return errors.New("token 解析失败") |
41 | } | 41 | } |
42 | + | ||
43 | +// CheckUserInfo 如果UserToken有效 返回:true 否则返回false | ||
44 | +func (tk *UserToken) CheckUserInfo() bool { | ||
45 | + return !(tk.UserId > 100000000 || tk.UserId <= 0) | ||
46 | +} |
@@ -49,15 +49,18 @@ func ParseContext(c beego.BaseController) *domain.Context { | @@ -49,15 +49,18 @@ func ParseContext(c beego.BaseController) *domain.Context { | ||
49 | userToken, ok := token.(*domain.UserToken) | 49 | userToken, ok := token.(*domain.UserToken) |
50 | if ok { | 50 | if ok { |
51 | // cache user info | 51 | // cache user info |
52 | - key := cache.KeyCompanyUser(companyId, userId) | ||
53 | - if userToken.UserId != 0 { | 52 | + key := cache.KeyCompanyUser(int(userToken.CompanyId), int(userToken.UserId)) |
53 | + if userToken.CheckUserInfo() { | ||
54 | if cacheItem, ok := cache.DefaultCache.Get(key); ok { | 54 | if cacheItem, ok := cache.DefaultCache.Get(key); ok { |
55 | v := cacheItem.(*authlib.DataUserMe) | 55 | v := cacheItem.(*authlib.DataUserMe) |
56 | userName = v.User.NickName | 56 | userName = v.User.NickName |
57 | } else { | 57 | } else { |
58 | requestToken, _ := userToken.GenerateToken() | 58 | requestToken, _ := userToken.GenerateToken() |
59 | authLib := authlib.NewApiAuthLib(constant.AUTH_SERVER_HOST).WithToken(requestToken) | 59 | authLib := authlib.NewApiAuthLib(constant.AUTH_SERVER_HOST).WithToken(requestToken) |
60 | - userInfo, err := authLib.MeInfo(authlib.RequestUserMeQuery{}) | 60 | + userInfo, err := authLib.MeInfo(authlib.RequestUserMeQuery{ |
61 | + UserId: int(userToken.UserId), | ||
62 | + CompanyId: int(userToken.CompanyId), | ||
63 | + }) | ||
61 | if err != nil || userInfo == nil || userInfo.User == nil { | 64 | if err != nil || userInfo == nil || userInfo.User == nil { |
62 | goto END | 65 | goto END |
63 | } | 66 | } |
-
请 注册 或 登录 后发表评论