mirror of
https://github.com/weloe/token-go.git
synced 2025-10-05 15:36:50 +08:00
fix: fix concurrent and share token logic
This commit is contained in:
@@ -33,11 +33,20 @@ func (e *Enforcer) createLoginToken(id string, loginModel *model.Login) (string,
|
|||||||
if tokenConfig.IsConcurrent && tokenConfig.IsShare {
|
if tokenConfig.IsConcurrent && tokenConfig.IsShare {
|
||||||
// reuse the previous token.
|
// reuse the previous token.
|
||||||
if v := e.GetSession(id); v != nil {
|
if v := e.GetSession(id); v != nil {
|
||||||
tokenValue = v.GetLastTokenByDevice(loginModel.Device)
|
var tokenSignList []*model.TokenSign
|
||||||
|
// if device is empty, get all tokenSign
|
||||||
|
if loginModel.Device == "" {
|
||||||
|
tokenSignList = v.TokenSignList
|
||||||
|
} else {
|
||||||
|
tokenSignList = v.GetFilterTokenSignSlice(loginModel.Device)
|
||||||
|
}
|
||||||
|
// get the last token value
|
||||||
|
if len(tokenSignList) != 0 && tokenSignList[len(tokenSignList)-1] != nil {
|
||||||
|
tokenValue = tokenSignList[len(tokenSignList)-1].Value
|
||||||
if tokenValue != "" {
|
if tokenValue != "" {
|
||||||
return tokenValue, nil
|
return tokenValue, nil
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user