Log out users with legacy auth

This commit is contained in:
Alex Gleason 2024-10-29 18:39:00 -05:00
parent d3a341c0c6
commit fcee59a68f
No known key found for this signature in database
GPG Key ID: 7211D1F99744FBB7
1 changed files with 11 additions and 0 deletions

View File

@ -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);