Пример #1
0
        public async Task InitUserInfoAsync(Metadata metadata, UserState profile, Token token)
        {
            // metadata should be set first
            await _metadataContainer.SetAsync(metadata).ConfigureAwait(false);

            await _userProfileContainer.SetAsync(profile).ConfigureAwait(false);

            var accountInformation = profile == null ? null : new Models.AccountInformation(profile.Roles);
            await _accountContainer.SetAsync(accountInformation).ConfigureAwait(false);

            await _sessionContainer.AddOrReplaceAsync(SessionInfo.CreateFromToken(token)).ConfigureAwait(false);
        }
Пример #2
0
        private async Task <Metadata> LoadDataInternalAsync(CancellationToken cancellationToken = default)
        {
            _connectivityService.CheckConnection();

            var profileResponse = await _platformClient.Endpoints.GetUserProfileAsync(cancellationToken).ConfigureAwait(false);

            var metadata = profileResponse.Metadata;

            cancellationToken.ThrowIfCancellationRequested();
            await _metadataContainer.SetAsync(metadata).ConfigureAwait(false);

            await _userProfileContainer.SetAsync(profileResponse.UserProfile).ConfigureAwait(false);

            return(metadata);
        }
Пример #3
0
        private async Task <Client.Services.Platform.Models.UserState> GetUserStateInternalAsync(CancellationToken cancellationToken = default)
        {
            cancellationToken.ThrowIfCancellationRequested();

            _connectivityService.CheckConnection();
            var profileResponse = await _platformClient.Endpoints.GetUserProfileAsync(cancellationToken).ConfigureAwait(false);

            var profile = profileResponse.UserProfile;

            cancellationToken.ThrowIfCancellationRequested();
            // metadata should be set first
            await _metadataContainer.SetAsync(profileResponse.Metadata).ConfigureAwait(false);

            await _userProfileContainer.SetAsync(profile).ConfigureAwait(false);

            await _accountContainer.SetAsync(new AccountInformation(profile.Roles)).ConfigureAwait(false);

            return(profile);
        }
        public async Task<UserProfileResponse> ApplyStatusChangeCode(string code)
        {
            try
            {
                code = code.ToUpperInvariant();

                _connectivityService.CheckConnection();

                var meetings = ShouldShareDeviceContacts(code)
                    ? await _meetingsService.GetMeetingsAsync().ConfigureAwait(false)
                    : new List<Meeting>(0);

                var request = new AcceptRequest(code, meetings.ToList());
                var response = await _platformClient.Endpoints.AcceptStatusChangeAsync(request).ConfigureAwait(false);
                if (response.Metadata != null)
                {
                    await _metadataContainer.SetAsync(response.Metadata).ConfigureAwait(false);
                }

                if (response.UserProfile != null)
                {
                    await _userProfileContainer.SetAsync(response.UserProfile).ConfigureAwait(false);
                }

                return response;
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "Failed to apply the code.");
                if (_serviceErrorHandler.TryHandle(ex, out var generatedException))
                {
                    generatedException.Rethrow();
                }

                throw;
            }
        }