Bug 465085 - Account settings can get clobbered if username is shared between instances
Summary: Account settings can get clobbered if username is shared between instances
Status: RESOLVED FIXED
Alias: None
Product: Tokodon
Classification: Applications
Component: general (show other bugs)
Version: unspecified
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Unassigned bugs mailing-list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-31 14:57 UTC by Raphael Gaschignard
Modified: 2023-02-17 12:36 UTC (History)
2 users (show)

See Also:
Latest Commit:
Version Fixed In:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Raphael Gaschignard 2023-01-31 14:57:18 UTC
SUMMARY
If you connect to multiple instances with the same username, the settings file clobbers over one of the instance settings on save.

The relevant bit in `account.cpp`, where we're using the username (`m_name`) to save the account settings:

```
void Account::writeToSettings(QSettings &settings) const
{
    settings.beginGroup(m_name);

    settings.setValue("token", m_token);
     /* snip */
    settings.endGroup();
}
```

I think the group needs to be set as something non-unique. At least `mastodon.sdf.org` sets the username as just the left part of the identifier, so `m_name` is only unique per instance, instead of globally unique.

A simple fix would be to simply use the instance + the name as the group
Comment 1 Joshua Goins 2023-02-03 22:42:56 UTC
I can confirm this is an issue, along with other inconsistencies due to some assumptions based on username uniqueness. I can fix this in a few days, but since you already know what's wrong, I highly suggest opening an MR (https://invent.kde.org/network/tokodon/-/merge_requests)! We'll have to support migrating from the old settings groups as well.
Comment 2 Raphael Gaschignard 2023-02-06 04:00:03 UTC
(In reply to Joshua Goins from comment #1)
> I can confirm this is an issue, along with other inconsistencies due to some
> assumptions based on username uniqueness. I can fix this in a few days, but
> since you already know what's wrong, I highly suggest opening an MR
> (https://invent.kde.org/network/tokodon/-/merge_requests)! We'll have to
> support migrating from the old settings groups as well.

Alright, will try to send something in!
Comment 3 Raphael Gaschignard 2023-02-06 05:12:23 UTC
I wrote a patch, but don't have push rights to the KDE repository. I tried to email in the merge request via a patch file and that failed as well. Do you have any guidance here?
Comment 4 Raphael Gaschignard 2023-02-06 05:19:55 UTC
Actually, I got this working (needed to fork the project, got a bit confused because the button wouldn't show up until I had added an SSH key... also reading the KDE contribution guide resolved my issue). Patch is up as a MR!
Comment 5 Carl Schwan 2023-02-17 12:36:26 UTC
This was merged and got into 23.02 :D