Merge branch 'v2_ChangeArchitecture' into v2_ChangeArchitecture_AddDiagnose

This commit is contained in:
2025-05-17 19:40:50 +02:00
committed by GitHub
37 changed files with 1376 additions and 863 deletions

View File

@@ -12,31 +12,13 @@ namespace Moonlight.ApiServer.Http.Controllers;
public class FrontendController : Controller
{
private readonly FrontendService FrontendService;
private readonly PluginService PluginService;
public FrontendController(FrontendService frontendService, PluginService pluginService)
public FrontendController(FrontendService frontendService)
{
FrontendService = frontendService;
PluginService = pluginService;
}
[HttpGet("frontend.json")]
public async Task<FrontendConfiguration> GetConfiguration()
=> await FrontendService.GetConfiguration();
[HttpGet("plugins/{assemblyName}")]
public async Task GetPluginAssembly(string assemblyName)
{
var assembliesMap = PluginService.GetAssemblies("client");
if (!assembliesMap.TryGetValue(assemblyName, out var path))
throw new HttpApiException("The requested assembly could not be found", 404);
var absolutePath = Path.Combine(
Directory.GetCurrentDirectory(),
path
);
await Results.File(absolutePath).ExecuteAsync(HttpContext);
}
}

View File

@@ -273,13 +273,22 @@ public class OAuth2Controller : Controller
if (await UserRepository.Get().AnyAsync(x => x.Email == email))
throw new HttpApiException("A account with that email already exists", 400);
var user = new User()
{
Username = username,
Email = email,
Password = HashHelper.Hash(password)
Password = HashHelper.Hash(password),
};
if (Configuration.Authentication.OAuth2.FirstUserAdmin)
{
var userCount = await UserRepository.Get().CountAsync();
if (userCount == 0)
user.PermissionsJson = "[\"*\"]";
}
return await UserRepository.Add(user);
}

View File

@@ -25,7 +25,7 @@
<form class="space-y-6" method="POST">
<div>
<label for="email" class="block text-sm font-medium leading-6 text-gray-100">Username</label>
<label for="username" class="block text-sm font-medium leading-6 text-gray-100">Username</label>
<div class="mt-2">
<input id="username" name="username" type="text" required class="block bg-white/5 w-full rounded-md border-0 py-1.5 text-gray-100 shadow-sm ring-1 ring-inset ring-gray-700 placeholder:text-gray-600 focus:ring-2 focus:ring-inset focus:ring-indigo-600 sm:text-sm sm:leading-6">
</div>