diff --git a/WebAPI/Controllers/HelloWorldController.cs b/WebAPI/Controllers/HelloWorldController.cs index 35b37b4..da479b8 100644 --- a/WebAPI/Controllers/HelloWorldController.cs +++ b/WebAPI/Controllers/HelloWorldController.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Threading.Tasks; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; +using WebAPI.Data; namespace WebAPI.Controllers { @@ -15,7 +16,7 @@ namespace WebAPI.Controllers public async Task HelloWorld() { await Task.Delay(5000); - return "Hello world!"; + return AppSettings.PterodactylAPIKey; } } } \ No newline at end of file diff --git a/WebAPI/Data/AppSettings.cs b/WebAPI/Data/AppSettings.cs new file mode 100644 index 0000000..4ee6b8a --- /dev/null +++ b/WebAPI/Data/AppSettings.cs @@ -0,0 +1,29 @@ +using Microsoft.Extensions.Configuration; +using Microsoft.Extensions.Logging; + +namespace WebAPI.Data +{ + public static class AppSettings + { + public static string PterodactylAPIKey { get; private set; } + public static void Init(IConfiguration configuration) + { + var fields = typeof(AppSettings).GetProperties(); + foreach (var propertyInfo in fields) + { + if (propertyInfo.PropertyType == typeof(string)) + { + propertyInfo.SetValue(null, configuration.GetValue(propertyInfo.Name)); + } + else if (propertyInfo.PropertyType == typeof(int)) + { + propertyInfo.SetValue(null, configuration.GetValue(propertyInfo.Name)); + } + else if (propertyInfo.PropertyType == typeof(double)) + { + propertyInfo.SetValue(null, configuration.GetValue(propertyInfo.Name)); + } + } + } + } +} \ No newline at end of file diff --git a/WebAPI/Data/Models/User.cs b/WebAPI/Data/Models/User.cs index 171348a..0a81354 100644 --- a/WebAPI/Data/Models/User.cs +++ b/WebAPI/Data/Models/User.cs @@ -3,5 +3,6 @@ namespace WebAPI.Data.Models public class User : BaseEntity { public int? PterodactylUserId { get; set; } + public int? ExternalAuthIdentifier { get; set; } } } \ No newline at end of file diff --git a/WebAPI/Startup.cs b/WebAPI/Startup.cs index 5ddd238..1772291 100644 --- a/WebAPI/Startup.cs +++ b/WebAPI/Startup.cs @@ -21,6 +21,7 @@ namespace WebAPI public Startup(IConfiguration configuration) { Configuration = configuration; + AppSettings.Init(configuration); } public IConfiguration Configuration { get; } @@ -29,7 +30,7 @@ namespace WebAPI public void ConfigureServices(IServiceCollection services) { services.AddControllers(); - services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo {Title = "WebAPI", Version = "v1"}); }); + services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new OpenApiInfo {Title = "Petrie Panel Web API", Version = "v1"}); }); services.AddDbContext(options => options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"))); } diff --git a/WebAPI/appsettings.Development.json b/WebAPI/appsettings.Development.json index 8983e0f..2900c0a 100644 --- a/WebAPI/appsettings.Development.json +++ b/WebAPI/appsettings.Development.json @@ -1,4 +1,7 @@ { + "ConnectionStrings": { + "DefaultConnection": "Host=my_host;Database=my_db;Username=my_user;Password=my_pw" + }, "Logging": { "LogLevel": { "Default": "Information", diff --git a/WebAPI/appsettings.json b/WebAPI/appsettings.json index 942e089..ddde2f5 100644 --- a/WebAPI/appsettings.json +++ b/WebAPI/appsettings.json @@ -1,6 +1,6 @@ { "ConnectionStrings": { - "DefaultConnection": "" + "DefaultConnection": "Host=my_host;Database=my_db;Username=my_user;Password=my_pw" }, "Logging": { "LogLevel": { @@ -9,5 +9,6 @@ "Microsoft.Hosting.Lifetime": "Information" } }, - "AllowedHosts": "*" + "AllowedHosts": "*", + "PterodactylAPIKey": "REPLACE_ME" }