Stage 11: account linking & merge (email + Telegram Login Widget) (#12)
This commit was merged in pull request #12.
This commit is contained in:
@@ -4,6 +4,8 @@ import (
|
||||
"context"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"github.com/google/uuid"
|
||||
)
|
||||
|
||||
// Cache is the in-memory write-through projection of the active rows in
|
||||
@@ -93,3 +95,19 @@ func (c *Cache) Remove(tokenHash string) {
|
||||
defer c.mu.Unlock()
|
||||
delete(c.byHash, tokenHash)
|
||||
}
|
||||
|
||||
// RemoveByAccount evicts every cached session belonging to accountID. The
|
||||
// account-merge flow uses it to drop a retired secondary account's sessions
|
||||
// (Stage 11); a linear scan is adequate at the cache's size.
|
||||
func (c *Cache) RemoveByAccount(accountID uuid.UUID) {
|
||||
if c == nil {
|
||||
return
|
||||
}
|
||||
c.mu.Lock()
|
||||
defer c.mu.Unlock()
|
||||
for hash, s := range c.byHash {
|
||||
if s.AccountID == accountID {
|
||||
delete(c.byHash, hash)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user