Exemplo n.º 1
0
        private void performRegistration()
        {
            if (focusNextTextbox())
            {
                registerShake.Shake();
                return;
            }

            usernameDescription.ClearErrors();
            emailAddressDescription.ClearErrors();
            passwordDescription.ClearErrors();

            processingOverlay.Show();

            Task.Run(() =>
            {
                bool success;
                RegistrationRequest.RegistrationRequestErrors errors = null;

                try
                {
                    errors  = api.CreateAccount(emailTextBox.Text, usernameTextBox.Text, passwordTextBox.Text);
                    success = errors == null;
                }
                catch (Exception)
                {
                    success = false;
                }

                Schedule(() =>
                {
                    if (!success)
                    {
                        if (errors != null)
                        {
                            usernameDescription.AddErrors(errors.User.Username);
                            emailAddressDescription.AddErrors(errors.User.Email);
                            passwordDescription.AddErrors(errors.User.Password);
                        }
                        else
                        {
                            passwordDescription.AddErrors(new[] { "Something happened... but we're not sure what." });
                        }

                        registerShake.Shake();
                        processingOverlay.Hide();
                        return;
                    }

                    api.Login(usernameTextBox.Text, passwordTextBox.Text);
                });
            });
        }
Exemplo n.º 2
0
        public void Configure(IAPIProvider apiProvider,
                              PisstaubeCacheDbContextFactory cacheDbContextFactory, IBeatmapSearchEngineProvider searchEngine,
                              PisstaubeDbContext dbContext)
        {
            Logger.Enabled        = true;
            Logger.Level          = LogLevel.Debug;
            Logger.GameIdentifier = "Pisstaube";
            Logger.Storage        = _dataStorage.GetStorageForDirectory("logs");

            dbContext.Database.Migrate();

            while (!searchEngine.IsConnected)
            {
                Logger.LogPrint("Search Engine is not yet Connected!", LoggingTarget.Database, LogLevel.Important);
                Thread.Sleep(1000);
            }

            cacheDbContextFactory.Get().Migrate();
            _osuContextFactory.Get().Migrate();

            JsonUtil.Initialize();

            apiProvider.Login(Environment.GetEnvironmentVariable("OSU_USERNAME"),
                              Environment.GetEnvironmentVariable("OSU_PASSWORD"));

            while (true)
            {
                if (!apiProvider.IsLoggedIn)
                {
                    Logger.LogPrint("Not Logged in yet...");
                    Thread.Sleep(1000);
                    continue;
                }
                if (apiProvider.State == APIState.Failing)
                {
                    Logger.LogPrint($"Failed to Login using Username {Environment.GetEnvironmentVariable("OSU_USERNAME")}", LoggingTarget.Network, LogLevel.Error);
                    Environment.Exit(1);
                }

                break;
            }
        }
Exemplo n.º 3
0
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IAPIProvider apiProvider,
                              PisstaubeCacheDbContextFactory cacheDbContextFactory, IBeatmapSearchEngineProvider searchEngine,
                              PisstaubeDbContext dbContext)
        {
            Logger.Enabled        = true;
            Logger.Level          = LogLevel.Debug;
            Logger.GameIdentifier = "Pisstaube";
            Logger.Storage        = _dataStorage.GetStorageForDirectory("logs");

            dbContext.Database.Migrate();

            while (!searchEngine.IsConnected)
            {
                Logger.LogPrint("Search Engine is not yet Connected!", LoggingTarget.Database, LogLevel.Important);
                Thread.Sleep(1000);
            }

            cacheDbContextFactory.Get().Migrate();
            _osuContextFactory.Get().Migrate();

            DogStatsd.Configure(new StatsdConfig {
                Prefix = "pisstaube"
            });

            JsonUtil.Initialize();

            apiProvider.Login(Environment.GetEnvironmentVariable("OSU_USERNAME"),
                              Environment.GetEnvironmentVariable("OSU_PASSWORD"));

            GlobalConfig.EnableCrawling = Environment.GetEnvironmentVariable("CRAWLER_DISABLED")?.ToLowerInvariant() == "false";
            GlobalConfig.EnableUpdating = Environment.GetEnvironmentVariable("UPDATER_DISABLED")?.ToLowerInvariant() == "false";

            while (true)
            {
                if (!apiProvider.IsLoggedIn)
                {
                    Logger.LogPrint("Not Logged in yet...");
                    Thread.Sleep(1000);
                    continue;
                }
                if (apiProvider.State == APIState.Failing)
                {
                    Logger.LogPrint($"Failed to Login using Username {Environment.GetEnvironmentVariable("OSU_USERNAME")}", LoggingTarget.Network, LogLevel.Error);
                    Environment.Exit(1);
                }

                break;
            }

            if (DebugUtils.IsDebugBuild)
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            app.UseFileServer(new FileServerOptions
            {
                FileProvider            = new PhysicalFileProvider(Path.Join(Directory.GetCurrentDirectory(), "data/wwwroot")),
                EnableDirectoryBrowsing = true,
            });

            app.UseMvc(routes => routes.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"));
        }