Exemple #1
0
        public async Task UpdateAsync(Action <UserSettings> updateFunc)
        {
            updateFunc(userSettings);

            await cookieManager.SetAsync(CookieKeys.WalletAddresses, userSettings.WalletAddress, 90);

            await cookieManager.SetAsync(CookieKeys.SecondaryWalletAddresses, string.Join(",", userSettings.SecondaryWalletAddresses), 90);

            await cookieManager.SetAsync(CookieKeys.CurrencyCode, userSettings.CurrencyCode, 90);

            await cookieManager.SetAsync(CookieKeys.DurationMode, userSettings.DurationMode, 90);

            await sessionStore.SetAsync(StoreKeys.Funds, userSettings.Funds);
        }
Exemple #2
0
        protected override async Task <HttpClient> CreateClientAsync()
        {
            var client = await base.CreateClientAsync();

            var item = await sessionStore.GetAsync <ApiLogin>(StoreKeys.JwtToken);

            if (item == null || item.ExpiresAt < DateTime.UtcNow)
            {
                item = await hostClient.LoginAsync();

                await sessionStore.SetAsync(StoreKeys.JwtToken, item);
            }

            client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", item.AccessToken);

            return(client);
        }