Bug 465085

Summary: Account settings can get clobbered if username is shared between instances
Product: [Applications] Tokodon Reporter: Raphael Gaschignard <raphael>
Component: generalAssignee: Unassigned bugs mailing-list <unassigned-bugs>
Status: RESOLVED FIXED    
Severity: normal CC: carl, josh
Priority: NOR    
Version: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed In:

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