Skip to content

A phone that leaves its last class keeps its diary sign-in but can no longer open «Дневник» or press «Выйти из дневника» #151

Closed

Description

@lumenpearson

What is broken.
The diary sign-in and the class memberships are meant to be independent. The server says so (current_diary: «a phone can be joined to a class without a diary account, and signed in to a diary without joining a class»). The phone's storage says so too: LessonsPreferences.clearSession keeps the diary keys on purpose, because «leaving a class is not leaving the diary». The navigation disagrees. The only way to reach the diary is Settings → «Дневник», which is a SettingsSectionScreen inside HomeShell. LessonsApp composes HomeShell only when the phone is in a class. Once the last class is gone, the app shows the join screen. The diary token (diary_token / diary_login) stays in DataStore, and nothing in the app can open the diary or sign out of it. The server-side diary session also stays, holding the sealed upstream credential, because POST /api/v1/diary/logout can no longer be sent from the phone. It lasts until the 30-day sweep in cron.py deletes it.

The failure scenario.

  1. A parent joins one class with its code, opens Settings → «Дневник» and signs in. DiaryRepositoryImpl.signIn writes diary_token and diary_login.
  2. The phone leaves that class. This happens in one of three ways:
    • the parent presses «Выйти» → «Выйти из класса?»;
    • the parent presses «Выйти из класса «…»»;
    • an admin revokes the device from «📱 Устений»… — more precisely from «📱 Устройства», or deletes the class. The next sync or management call then gets a 401 and calls sessionRepository.leaveActive() in the background, with no confirmation.
  3. removeSession / clearSession drop the memberships and set onboarding_done. By design they leave the diary keys alone. SessionEffects.onSignedOut stops sync, alerts and the widget, and does not touch the diary either.
  4. AppShellViewModel sees session == null and emits signedIn = false. LessonsApp then shows JoinScreen, and HomeShell is no longer composed.
  5. JoinScreen offers the code field and «Адрес сервера», and nothing else. DiaryScreen cannot be reached, so neither can its «Выйти из дневника». The parent cannot read the diary and cannot sign out of it, although the phone is still signed in. The confirmation for this sign-out, «Выйти из дневника?», promises that the two accounts are separate.
  6. The only way back is to join a class again. Clearing the app's data removes the local token without the server's logout. The server row, with the family's sealed upstream bearer, then stays until DIARY_SESSION_TTL (30 days since last use) removes it.

Where.

  • android/app/src/main/kotlin/com/lumenpearson/lessons/navigation/LessonsApp.kt:178-207: the no-class branch (false ->) shows OnboardingScreen / JoinScreen, and only true -> composes HomeShell.
  • android/app/src/main/kotlin/com/lumenpearson/lessons/navigation/LessonsApp.kt:787-798: the only caller of SettingsSectionScreen.
  • android/app/src/main/kotlin/com/lumenpearson/lessons/ui/settings/SettingsScreen.kt:339-349: the only place DiaryScreen is composed.
  • android/app/src/main/kotlin/com/lumenpearson/lessons/ui/diary/DiaryScreen.kt:197, :414: «Выйти из дневника».
  • android/app/src/main/kotlin/com/lumenpearson/lessons/ui/AppShellViewModel.kt:98-99: signedIn is «any class session».
  • android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/datastore/LessonsPreferences.kt:127-178: removeSession / clearSession keep the diary keys on purpose (comment at :151-158).
  • android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/repository/SessionRepositoryImpl.kt:153-184: leave / signOut.
  • android/core/data/src/main/kotlin/com/lumenpearson/lessons/core/data/di/LessonsContainer.kt:223, :295: a 401 on the class token calls leaveActive().
  • server/app/api/diary.py:114-117: the stated independence of the two tokens.
  • server/app/api/cron.py:49, :101-119: the stranded server row lasts until the 30-day sweep.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions