Skip to content

tg auth login / login-qr don't update activeAccount in config.json, so the next command uses the configured account #62

Closed

Description

@neoromantic

tg auth login and tg auth login-qr make the account they log in active in data.db, but they don't touch activeAccount in config.json. Every command except tg config and tg skill applies activeAccount again at startup, so with the key set the command after a login uses the configured account, not the one just logged in.

Example: account 1 exists and config.json has "activeAccount": 1. tg auth login --phone +15550000002 adds account 2 and makes it active; the next tg chats list reads account 1 again.

Today the workaround is tg accounts switch --id <id>, which since #61 writes the new ID to activeAccount when the key is set (docs/configuration.md, Runtime Behavior).

Fix: after a successful login, write the account's ID to activeAccount when config.json already sets it (the same rule as tg accounts switch), and never create config.json otherwise. Done when an offline test covers both login paths with and without the key; that likely needs a hook in AuthDependencies so the test doesn't reach Telegram.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions