Repository navigation
Description
What is broken.
_session_for in the bot's diary handler is supposed to drop a session opened against a diary the class no longer uses. Its docstring says the stale row should become «войдите снова» "rather than a screen that silently talks to the diary the class left". It only matches on the provider, though, not on the region. For «Сетевой город», one provider covers many regional servers, and a session's credential names its own region. Rebinding a class from one region to another in «⚙️ Класс» expires no session: neither the unbind step nor the new binding touches diary_sessions. So a family's old session is still found and still read from the old region's server, under a class that is now bound somewhere else. A Petersburg ↔ «Сетевой город» rebind is filtered correctly. A region ↔ region rebind is not.
The failure scenario.
- Class «9А» is bound in «⚙️ Класс» → «📒 Электронный дневник» to «Сетевой город», region A, school X. A parent presses «🔐 Войти» and signs in on
/diary/signin.diary_webstores aDiarySessionwithprovider='netschool',region='A'andclass_id=9А, and the sealed credential's JSON names region A and school X. - The admin presses the diary button on the class card.
class_diary_bindunbinds «Дневник отвязан» by clearing the four class columns only. The admin then binds «Сетевой город» → region B → school Y throughclass_diary_regionandclass_diary_school. Neither step expires the parent's row. - The parent presses «📒 Мой дневник».
_boundis true because binding B is valid._session_forfilters onDiarySession.provider == 'netschool'with no region term, so it returns the region-A row, andupstream_ofunseals it without complaint. DiaryServicecallsNetSchoolProvider.open, which reads the region from the credential and builds aNetSchoolConnectionagainst region A's origin._showthen fetches the students and the day from region A and draws the old school's diary on the screen of a class now bound to region B, school Y. The parent should have been sent to «войдите снова», the same as after a Petersburg → «Сетевой город» rebind.- The stale row does not age out. The cron keep-alive pings every live
netschoolsession without looking at the class's binding, so the region-A session stays alive until the parent presses «Выйти». It dies on its own only if region A is removed from the allow-list, because thenopenreturns a dead connection.
Where.
- server/app/bot/handlers/diary.py:86-99. The query's only binding filter is
provider_clause(line 91).b.regionfrom line 83 is never compared withDiarySession.region. The intent is stated at lines 76-80. - server/app/bot/handlers/manage.py:2389-2395 (unbind), 2426-2429 (bind Petersburg), 2582-2585 (bind «Сетевой город»). None of these expires a session. Keeping sessions on a plain unbind is deliberate (docstring at 2378-2382), so the region check has to happen at lookup.
- server/app/api/diary_web.py:323-330 stores the session's
region. - server/app/providers/netschool/provider.py:204-215 opens the connection at the credential's own region.
- server/app/services/diary_keepalive.py:102-109 keeps every live
netschoolrow alive regardless of binding.
Metadata
Metadata
Assignees
Type
Projects
- StatusShow more project fieldsDone
Activity
Let a phone register a diary session it opened itself, and fix what t…
Document how a diary session now reaches the server, the region catal…
Close out the batch in HANDOVER while its pull request is still open