fix(auth): Session-Restore erst mit vollständiger lokaler Session

Stellt hasUnlockedLocalSession für UI-Wiederherstellung und
enforceUnlockedSession wieder her; persistSessionUserId setzt userId
nur bei Angabe in der Server-Antwort.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-05-31 11:37:50 +02:00
co-authored by Cursor
parent 728c40f936
commit 57f63ad486
3 changed files with 35 additions and 6 deletions
+19
View File
@@ -32,3 +32,22 @@ describe('local session unlock checks', () => {
expect(hasUnlockedLocalCrypto()).toBe(false)
})
})
describe('persistSessionUserId', () => {
beforeEach(() => {
localStorage.clear()
})
it('stores userId when provided', async () => {
const { persistSessionUserId } = await import('./auth.js')
persistSessionUserId('user-42')
expect(localStorage.getItem('active_userid')).toBe('user-42')
})
it('does not clear existing userId when omitted', async () => {
const { persistSessionUserId } = await import('./auth.js')
localStorage.setItem('active_userid', 'user-1')
persistSessionUserId(undefined)
expect(localStorage.getItem('active_userid')).toBe('user-1')
})
})