|
|
|
@ -80,8 +80,6 @@ func (a *authDatabase) BatchSetTokenMapByUidPid(ctx context.Context, tokens []st
|
|
|
|
|
|
|
|
|
|
// Create Token.
|
|
|
|
|
func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformID int) (string, error) {
|
|
|
|
|
isAdmin := authverify.IsManagerUserID(userID, a.adminUserIDs)
|
|
|
|
|
if !isAdmin {
|
|
|
|
|
tokens, err := a.cache.GetAllTokensWithoutError(ctx, userID)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return "", err
|
|
|
|
@ -106,7 +104,6 @@ func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformI
|
|
|
|
|
log.ZDebug(ctx, "kicked token in create token", "token", k)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
claims := tokenverify.BuildClaims(userID, platformID, a.accessExpire)
|
|
|
|
|
token := jwt.NewWithClaims(jwt.SigningMethodHS256, claims)
|
|
|
|
@ -115,11 +112,9 @@ func (a *authDatabase) CreateToken(ctx context.Context, userID string, platformI
|
|
|
|
|
return "", errs.WrapMsg(err, "token.SignedString")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if !isAdmin {
|
|
|
|
|
if err = a.cache.SetTokenFlagEx(ctx, userID, platformID, tokenString, constant.NormalToken); err != nil {
|
|
|
|
|
return "", err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tokenString, nil
|
|
|
|
|
}
|
|
|
|
@ -224,9 +219,6 @@ func (a *authDatabase) checkToken(ctx context.Context, tokens map[int]map[string
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//var adminTokenMaxNum = a.multiLogin.MaxNumOneEnd
|
|
|
|
|
//if a.multiLogin.Policy == constant.Customize {
|
|
|
|
|
// adminTokenMaxNum = a.multiLogin.CustomizeLoginNum[constant.AdminPlatformID]
|
|
|
|
|
//}
|
|
|
|
|
//l := len(adminToken)
|
|
|
|
|
//if platformID == constant.AdminPlatformID {
|
|
|
|
|
// l++
|
|
|
|
@ -234,5 +226,8 @@ func (a *authDatabase) checkToken(ctx context.Context, tokens map[int]map[string
|
|
|
|
|
//if l > adminTokenMaxNum {
|
|
|
|
|
// kickToken = append(kickToken, adminToken[:l-adminTokenMaxNum]...)
|
|
|
|
|
//}
|
|
|
|
|
if platformID == constant.AdminPlatformID {
|
|
|
|
|
kickToken = append(kickToken, adminToken...)
|
|
|
|
|
}
|
|
|
|
|
return deleteToken, kickToken, nil
|
|
|
|
|
}
|
|
|
|
|