From fcee59a68f5ff4b98b20cf2fcc51323763469a36 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Tue, 29 Oct 2024 18:39:00 -0500 Subject: [PATCH] Log out users with legacy auth --- src/reducers/auth.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/reducers/auth.ts b/src/reducers/auth.ts index f8ff86274..a0f66eeba 100644 --- a/src/reducers/auth.ts +++ b/src/reducers/auth.ts @@ -26,6 +26,17 @@ import type { UnknownAction } from 'redux'; const STORAGE_KEY = 'soapbox:auth'; const SESSION_KEY = 'soapbox:auth:me'; +// Log out legacy Nostr/Ditto users. +for (let i = 0; i < localStorage.length; i++) { + const key = localStorage.key(i); + + if (key && /^soapbox:nostr:auth:[0-9a-f]{64}$/.test(key)) { + localStorage.clear(); + sessionStorage.clear(); + location.reload(); + } +} + /** Get current user's URL from session storage. */ function getSessionUser(): string | undefined { const value = sessionStorage.getItem(SESSION_KEY);