- user GetUserTag in jxcontext.Context.GetUserName
This commit is contained in:
@@ -76,3 +76,16 @@ func (a *AuthInfo) GetAuthID() string {
|
||||
func (a *AuthInfo) GetAuthType() string {
|
||||
return a.AuthBindInfo.Type
|
||||
}
|
||||
|
||||
func (a *AuthInfo) GetUserTag() string {
|
||||
userTag := a.UserID2
|
||||
if userTag == "" {
|
||||
if a.AuthBindInfo.UserHint != nil {
|
||||
userTag = a.AuthBindInfo.UserHint.Mobile
|
||||
}
|
||||
if userTag == "" {
|
||||
userTag = a.AuthBindInfo.AuthID
|
||||
}
|
||||
}
|
||||
return userTag
|
||||
}
|
||||
|
||||
@@ -115,3 +115,7 @@ func (a *LoginInfo) GetAuthID() string {
|
||||
func (a *LoginInfo) GetAuthType() string {
|
||||
return a.LoginType
|
||||
}
|
||||
|
||||
func (a *LoginInfo) GetUserTag() string {
|
||||
return a.ID
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import (
|
||||
type IAuther interface {
|
||||
GetAuthID() string
|
||||
GetAuthType() string
|
||||
GetUserTag() string
|
||||
}
|
||||
|
||||
type Context struct {
|
||||
@@ -96,7 +97,7 @@ func New(rootTask tasksch.ITask, token string, w http.ResponseWriter, r *http.Re
|
||||
func (ctx *Context) GetUserName() string {
|
||||
userName := ctx.token
|
||||
if ctx.userInfo != nil {
|
||||
userName = ctx.userInfo.GetAuthID()
|
||||
userName = ctx.userInfo.GetUserTag()
|
||||
}
|
||||
if len(userName) > MaxUserNameLen {
|
||||
userName = userName[:MaxUserNameLen]
|
||||
|
||||
Reference in New Issue
Block a user