Exemplo n.º 1
0
        private void linkDeleteBackup_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var caption = RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_header");
            var content = RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_body");

            if (MessageBox.Show(
                    content,
                    caption,
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                try {
                    var restService      = _authAuthService.GetRestService();
                    var cloudSyncService = new CloudSyncService(_authAuthService.GetRestService());
                    if (restService != null && cloudSyncService.DeleteAccount())
                    {
                        MessageBox.Show(
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_success_body"),
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_success_header"),
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation
                            );

                        _settings.GetPersistent().CloudUploadTimestamp = 0;
                        _authAuthService.UnAuthenticate();
                        _playerItemDao.ResetOnlineSyncState();
                        _settings.GetPersistent().BuddySyncUserIdV3 = null;
                    }
                    else
                    {
                        MessageBox.Show(
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_body"),
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_header"),
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error
                            );
                    }
                }
                catch (Exception ex) {
                    Logger.Warn("Error deleting account", ex);
                    MessageBox.Show(
                        RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_body"),
                        RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_header"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );
                }
            }

            UpdateUi();
        }
Exemplo n.º 2
0
        public AccessStatus CheckAuthentication()
        {
            if (MemoryCache.Default[CacheKey] is AccessStatus cached)
            {
                return(cached);
            }

            if (_authenticationProvider.CanMigrate())
            {
                // We have a legacy access token, can migrate to the new cloud solution.
                return(Migrate());
            }
            else if (_authenticationProvider.HasToken())
            {
                var result = IsTokenValid(_authenticationProvider.GetUser(), _authenticationProvider.GetToken());
                MemoryCache.Default.Set(CacheKey, result, DateTimeOffset.Now.AddDays(1));

                if (result == AccessStatus.Unauthorized)
                {
                    Logger.Warn("Existing authentication token is invalid, clearing authentication provider");
                    _authenticationProvider.SetToken(string.Empty, string.Empty);
                    _playerItemDao.ResetOnlineSyncState();
                }

                return(result);
            }
            else
            {
                MemoryCache.Default.Set(CacheKey, false, DateTimeOffset.Now.AddDays(1));
            }

            return(AccessStatus.Unauthorized);
        }
Exemplo n.º 3
0
        private void linkDeleteBackup_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var caption = RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_header");
            var content = RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_body");

            if (MessageBox.Show(
                    content,
                    caption,
                    MessageBoxButtons.YesNo,
                    MessageBoxIcon.Exclamation,
                    MessageBoxDefaultButton.Button2) == DialogResult.Yes)
            {
                try {
                    if (_azureSyncService.DeleteAccount())
                    {
                        MessageBox.Show(
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_success_body"),
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_success_header"),
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Exclamation
                            );

                        _authAuthService.UnAuthenticate();
                        _playerItemDao.ResetOnlineSyncState();
                    }
                    else
                    {
                        MessageBox.Show(
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_body"),
                            RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_header"),
                            MessageBoxButtons.OK,
                            MessageBoxIcon.Error
                            );
                    }
                }
                catch (Exception ex) {
                    Logger.Warn("Error deleting account", ex);
                    MessageBox.Show(
                        RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_body"),
                        RuntimeSettings.Language.GetTag("iatag_ui_backup_deleteaccount_failure_header"),
                        MessageBoxButtons.OK,
                        MessageBoxIcon.Error
                        );
                }
            }
        }
Exemplo n.º 4
0
 public void ResetOnlineSyncState()
 {
     ThreadExecuter.Execute(
         () => _repo.ResetOnlineSyncState()
         );
 }