Skip to content
This repository has been archived by the owner on May 1, 2024. It is now read-only.

Potential error in the SecureStorageAccountStore Migration Helper Class #441

Open
1 of 3 tasks
yanxiaodi opened this issue May 14, 2020 · 3 comments
Open
1 of 3 tasks

Comments

@yanxiaodi
Copy link

Xamarin.Auth Issue

I checked the code of SecureStorageAccountStore here: https://github.com/xamarin/Xamarin.Auth/wiki/Migrating-from-AccountStore-to-Xamarin.Essentials-SecureStorage

public static async Task MigrateAllAccountsAsync(string serviceId, IEnumerable<Account> accountStoreAccounts)
    {
        var wasMigrated = await SecureStorage.GetAsync("XamarinAuthAccountStoreMigrated");
        if (wasMigrated == "1")
            return;
        await SecureStorage.SetAsync("XamarinAuthAccountStoreMigrated", "1");

I am wondering if it is a bug? It seems like that this helper only supports one serviceId. If there are multiple serviceIds, only the first account can be migrated because XamarinAuthAccountStoreMigrated has been set to 1 when migrating the others.

Version

  • nuget version =
  • component version =
  • sample

Expected behaviour

The helper should support multiple accounts.

Actual behaviour

To fix it, we can include the serviceId in the key, such as:

await SecureStorage.SetAsync($"XamarinAuthAccountStore{serviceId}Migrated", "1");
@yanxiaodi
Copy link
Author

@ghost
Copy link

ghost commented May 26, 2020

I believe there's a typo in one of the instances - the $ is inside the string instead of prefixing it.

@yanxiaodi
Copy link
Author

yanxiaodi commented May 27, 2020

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant