- NewWithUserName

This commit is contained in:
gazebo
2018-11-01 20:18:27 +08:00
parent 1e56ec2460
commit 6d98034c13

View File

@@ -6,6 +6,7 @@ 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"
)
@@ -28,13 +29,18 @@ var (
)
func init() {
AdminCtx = &Context{
rootTask: nil,
token: "jxadmin",
w: nil,
r: nil,
AdminCtx = NewWithUserName(nil, "jxadmin", nil, nil)
}
func NewWithUserName(rootTask tasksch.ITask, userName string, w http.ResponseWriter, r *http.Request) (ctx *Context) {
ctx = &Context{
rootTask: rootTask,
token: userName,
w: w,
r: r,
mapData: make(map[interface{}]interface{}),
}
return ctx
}
func New(rootTask tasksch.ITask, token string, w http.ResponseWriter, r *http.Request) (ctx *Context, errCode string, err error) {
@@ -47,7 +53,7 @@ func New(rootTask tasksch.ITask, token string, w http.ResponseWriter, r *http.Re
}
ctx.userInfo, err = auth.GetUserInfo(token)
if err != nil && beego.BConfig.RunMode == "prod" {
// globals.SugarLogger.Warnf("token is invalid, token:%s", token)
globals.SugarLogger.Warnf("token is invalid, token:%s", token)
// return nil, "", err
}
return ctx, "", nil