mirror of
https://github.com/chriswritescode-dev/opencode-manager.git
synced 2026-12-06 04:44:21 +01:00
fix(device-pairing): clean up push subscriptions on admin reset and share URL helpers
The admin password reset finds the admin case-insensitively and deletes the push subscriptions of the sessions it ends. The app re-sends its push subscription once per signed-in session so revoke reaches re-signed-in devices, and the upsert keeps the stored device name. Plain-HTTP and URL parsing checks are shared helpers.
This commit is contained in:
1 parent
cbe4f7ed9e
commit
6e398c4d40
21 files changed
+540
-85
No files matched your search
@@ -26,7 +26,16 @@ export function ensurePushSubscriptionsTable(db: Database): void {
|
||||
db.run('CREATE INDEX IF NOT EXISTS idx_push_sub_session ON push_subscriptions(session_id)')
|
||||
}
|
||||
|
||||
/** Deletes the push subscriptions registered by any of the given Better Auth sessions. */
|
||||
export function deletePushSubscriptionsForSessions(db: Database, sessionIds: string[]): number {
|
||||
if (sessionIds.length === 0) return 0
|
||||
const placeholders = sessionIds.map(() => '?').join(', ')
|
||||
return db
|
||||
.prepare(`DELETE FROM push_subscriptions WHERE session_id IN (${placeholders})`)
|
||||
.run(...sessionIds).changes
|
||||
}
|
||||
|
||||
/** Deletes the push subscriptions a revoked Better Auth session registered. */
|
||||
export function deletePushSubscriptionsForSession(db: Database, sessionId: string): number {
|
||||
return db.prepare('DELETE FROM push_subscriptions WHERE session_id = ?').run(sessionId).changes
|
||||
return deletePushSubscriptionsForSessions(db, [sessionId])
|
||||
}
|
||||
Reference in new issue
Block a user