- output warning on prod when token is invliad.

This commit is contained in:
gazebo
2018-11-01 19:24:27 +08:00
parent df54e49bcd
commit 0428e3580f
2 changed files with 7 additions and 1 deletions

View File

@@ -76,5 +76,5 @@ func GetUserInfo(token string) (loginInfo *LoginInfo, err error) {
if err = globals.Cacher.GetAs(token, loginInfo); err == nil {
return loginInfo, nil
}
return nil, err
return nil, errors.New("token过期或无效请重新登录")
}

View File

@@ -6,6 +6,8 @@ import (
"git.rosy.net.cn/jx-callback/business/jxcallback/auth"
"git.rosy.net.cn/jx-callback/business/jxutils/tasksch"
"git.rosy.net.cn/jx-callback/globals"
"github.com/astaxie/beego"
)
type Context struct {
@@ -39,6 +41,10 @@ func New(rootTask tasksch.ITask, token string, w http.ResponseWriter, r *http.Re
mapData: make(map[interface{}]interface{}),
}
ctx.userInfo, err = auth.GetUserInfo(token)
if err != nil && beego.BConfig.RunMode == "prod" {
globals.SugarLogger.Warnf("token is invalid, token:%s", token)
return nil, "", err
}
return ctx, "", nil
}