세션 해제 콜백 추가

This commit is contained in:
2023-12-25 22:06:57 +09:00
parent 08802176cb
commit 46f7d358ed
6 changed files with 110 additions and 27 deletions

View File

@ -161,7 +161,12 @@ func newConsumerWithRedis(ctx context.Context, redisUrl string, ttl time.Duratio
switch msg.Channel {
case deleteChannel:
sk := storagekey(msg.Payload)
consumer.delete(sk)
old := consumer.delete(sk)
if old != nil {
for _, f := range consumer.onSessionInvalidated {
f(old.Account)
}
}
}
}
}
@ -286,3 +291,7 @@ func (c *consumer_redis) Touch(pk string) (Authorization, error) {
return Authorization{}, nil
}
func (c *consumer_redis) RegisterOnSessionInvalidated(cb func(primitive.ObjectID)) {
c.onSessionInvalidated = append(c.onSessionInvalidated, cb)
}