Skip to content

A Petersburg account with a second factor cannot sign in, and the app says its password is wrong #343

Open

Description

@lumenpearson

What is wrong

A Petersburg diary account that has a second factor turned on cannot sign in through the app, and the app tells the parent their password is wrong. The second factor is a code from an SMS or from the MAX messenger.

The app's Petersburg sign-in (android/core/data/.../upstream/PetersburgSignIn.kt) sends type, login, password, and activation_code: null. It has no step that asks for a code. When the diary answers 401, the app reads it as BadCredentials and shows «Не удалось войти — Неверный логин или пароль». The server's own PetersburgClient.login (server/app/providers/petersburg/client.py), which the app's sign-in ports, has the same shape.

Failure scenario

Found on 5 October 2026, in a check on the emulator with a real Petersburg account the owner supplied. The debug build pointed at production, and a temporary route sent the phone's traffic for the diary through a Russian line.

  • The app's sign-in reached dnevnik2.petersburgedu.ru, and the diary answered 401. The app said the login or the password was wrong.
  • The same request sent directly from a computer was also answered 401.
  • The owner then signed in to the diary's own website with the same login and password. The password is right: the site asked for a code from an SMS or from MAX.

So a family whose account has the second factor on cannot use the diary in the app at all. They are told something false: retyping the same password can never succeed. It costs them attempts on the account, and it costs us their trust.

What is known and what is not

  • The site's own code (its main bundle, read on 5 October) builds the login body as {type, login, password, activation_code} and posts it to /api/user/auth/login, the same path the app uses. The site also sends X-Requested-With: XMLHttpRequest, which the app does not.

  • Not known:

    • how the diary tells a client that a code is needed;
    • whether the code then goes in activation_code;
    • whether the code is sent by the first request or needs a separate call.

    The diary answers a made-up account with the same 772-byte HTML 401 as a real one, so the answer the app sees today does not show it. Finding this out takes a real sign-in with the code at hand, or reading the site's sign-in flow further. The session that found this was refused further probing of the diary's sign-in, and did not pursue it.

What a fix has to be

  1. Stop telling a parent their password is wrong when it may not be. At minimum, the sign-in screen's 401 sentence covers both cases until the diary's answer can tell them apart. For example: «Дневник не пустил: неверный пароль или нужен код из СМС».
  2. Support the second factor. Find out what the diary answers when a code is needed. Then add a step to the app's sign-in that asks for the code and sends it, most likely in activation_code. The server's password sign-in path (/api/v1/diary/login, /diary/signin) needs the same.

Either part needs a real account with its code at hand to verify.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    • Status
      Ready

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions