diff --git a/server/visitor.go b/server/visitor.go index 04bd822..b96563d 100644 --- a/server/visitor.go +++ b/server/visitor.go @@ -330,9 +330,13 @@ func (v *visitor) SetUser(u *user.User) { v.mu.Lock() defer v.mu.Unlock() shouldResetLimiters := v.user.TierID() != u.TierID() // TierID works with nil receiver - v.user = u + v.user = u // u may be nil! if shouldResetLimiters { - v.resetLimitersNoLock(u.Stats.Messages, u.Stats.Emails, true) + var messages, emails int64 + if u != nil { + messages, emails = u.Stats.Messages, u.Stats.Emails + } + v.resetLimitersNoLock(messages, emails, true) } }