mirror of
https://github.com/casdoor/casdoor.git
synced 2025-07-04 13:20:19 +08:00
Add removeExtraSessionIds()
This commit is contained in:
@ -98,6 +98,12 @@ func UpdateSession(id string, session *Session) bool {
|
||||
return affected != 0
|
||||
}
|
||||
|
||||
func removeExtraSessionIds(session *Session) {
|
||||
if len(session.SessionId) > 100 {
|
||||
session.SessionId = session.SessionId[(len(session.SessionId) - 100):]
|
||||
}
|
||||
}
|
||||
|
||||
func AddSession(session *Session) bool {
|
||||
dbSession := GetSingleSession(session.GetId())
|
||||
if dbSession == nil {
|
||||
@ -120,6 +126,8 @@ func AddSession(session *Session) bool {
|
||||
}
|
||||
}
|
||||
|
||||
removeExtraSessionIds(session)
|
||||
|
||||
return UpdateSession(dbSession.GetId(), dbSession)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user