From 9dc878c51738cbaa4f4baf441f7370f53d945c75 Mon Sep 17 00:00:00 2001 From: CodeLiturgy Date: Sat, 10 Sep 2022 06:05:24 +0100 Subject: [PATCH] Cookie Auth working --- .../Context/Extensions/ModelBuilderExtensions.cs | 3 +++ BlueWest.Api/Program.cs | 10 +++++----- BlueWest.Api/Startup.cs | 7 +++++-- BlueWest.Api/Users/ApplicationUserDbContext.cs | 1 - BlueWest.Api/config.json | 2 +- 5 files changed, 14 insertions(+), 9 deletions(-) diff --git a/BlueWest.Api/Context/Extensions/ModelBuilderExtensions.cs b/BlueWest.Api/Context/Extensions/ModelBuilderExtensions.cs index f2a2157..46012ca 100644 --- a/BlueWest.Api/Context/Extensions/ModelBuilderExtensions.cs +++ b/BlueWest.Api/Context/Extensions/ModelBuilderExtensions.cs @@ -96,6 +96,9 @@ namespace BlueWest.WebApi.EF.Model private static ModelBuilder CurrencyModel(this ModelBuilder modelBuilder) { + modelBuilder.Entity().ToTable("Currencies"); + modelBuilder.Entity().ToTable("Countries"); + modelBuilder .Entity() .HasMany(ub => ub.Countries) diff --git a/BlueWest.Api/Program.cs b/BlueWest.Api/Program.cs index 94daa71..fa26ba7 100644 --- a/BlueWest.Api/Program.cs +++ b/BlueWest.Api/Program.cs @@ -53,13 +53,13 @@ namespace BlueWest.WebApi .UseContentRoot(Directory.GetCurrentDirectory()) .Build(); - MainHost.RunAsync(); + MainHost.Run(); - var tryGetEventManager = MainHost.Services.GetService(typeof(EventManager)); - _ = MainHost.Services.GetService(typeof(ExchangeInterface)); + //var tryGetEventManager = MainHost.Services.GetService(typeof(EventManager)); + // _ = MainHost.Services.GetService(typeof(ExchangeInterface)); - if(tryGetEventManager == null) Console.WriteLine($"Failed to get {nameof(EventManager)} Service."); + /*if(tryGetEventManager == null) Console.WriteLine($"Failed to get {nameof(EventManager)} Service."); if (tryGetEventManager is EventManager eventManager) { @@ -67,7 +67,7 @@ namespace BlueWest.WebApi System.Threading.Thread.Sleep(2500); _threadServer = new ThreadServer(eventManager); _threadServer.Init(); - } + }*/ } diff --git a/BlueWest.Api/Startup.cs b/BlueWest.Api/Startup.cs index 0c513cf..427cbc7 100644 --- a/BlueWest.Api/Startup.cs +++ b/BlueWest.Api/Startup.cs @@ -69,7 +69,9 @@ namespace BlueWest.WebApi // Set the comments path for the Swagger JSON and UI. var xmlFile = $"{Assembly.GetExecutingAssembly().GetName().Name}.xml"; + var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile); + options.IncludeXmlComments(xmlPath); options.AddSecurityDefinition("Bearer", new OpenApiSecurityScheme @@ -117,6 +119,8 @@ namespace BlueWest.WebApi services .AddSingleton(); + services.AddAuthServerServices(MyAllowSpecificOrigins, _configuration, _environment); + services.AddScoped(); switch (allowedDatabase) { @@ -132,10 +136,8 @@ namespace BlueWest.WebApi throw new InvalidOperationException("config.json doesn't specify a valid database. Use mysql or sqlite."); } - services = services.AddAuthServerServices(MyAllowSpecificOrigins, _configuration, _environment); - services.AddScoped(); // services.AddGrpc(); @@ -164,6 +166,7 @@ namespace BlueWest.WebApi //app.UseHttpsRedirection(); + app.UseRouting(); app.UseCors(MyAllowSpecificOrigins); diff --git a/BlueWest.Api/Users/ApplicationUserDbContext.cs b/BlueWest.Api/Users/ApplicationUserDbContext.cs index 291f650..9cee546 100644 --- a/BlueWest.Api/Users/ApplicationUserDbContext.cs +++ b/BlueWest.Api/Users/ApplicationUserDbContext.cs @@ -51,7 +51,6 @@ public class ApplicationUserDbContext : IdentityDbContext< protected override void OnModelCreating(ModelBuilder builder) { base.OnModelCreating(builder); - builder.Entity().ToTable("UserRoles"); builder.Entity(b => diff --git a/BlueWest.Api/config.json b/BlueWest.Api/config.json index e55950c..8fee60d 100644 --- a/BlueWest.Api/config.json +++ b/BlueWest.Api/config.json @@ -1,4 +1,4 @@ { - "database": "sqlite", // use sqlite or mysql + "database": "sqlite", "environment": "dev" } \ No newline at end of file