mirror of
https://github.com/zoriya/Kyoo.git
synced 2025-07-07 10:14:13 -04:00
Using static files for the login webapp
This commit is contained in:
parent
a4b4622fa5
commit
b6d92a96c1
@ -3,11 +3,11 @@
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Kyoo - Login</title>
|
||||
<link rel="stylesheet" type="text/css" href="login/lib/bootstrap.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="login/login.css" />
|
||||
<link rel="stylesheet" type="text/css" href="login/material-icons.css" />
|
||||
<script src="login/lib/jquery.min.js"></script>
|
||||
<script src="login/lib/bootstrap.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="lib/bootstrap.min.css" />
|
||||
<link rel="stylesheet" type="text/css" href="login.css" />
|
||||
<link rel="stylesheet" type="text/css" href="material-icons.css" />
|
||||
<script src="lib/jquery.min.js"></script>
|
||||
<script src="lib/bootstrap.min.js"></script>
|
||||
</head>
|
||||
<body style="height: 100vh; align-items: center;" class="d-flex">
|
||||
<div class="container pb-5">
|
||||
@ -85,6 +85,6 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script src="login/login.js"></script>
|
||||
<script src="login.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
@ -92,7 +92,7 @@
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</ResolvedFileToPublish>
|
||||
<ResolvedFileToPublish Include="@(LoginFiles->'%(FullPath)')" Exclude="@(ResolvedFileToPublish)">
|
||||
<RelativePath>login/%(LoginFiles.RecursiveDir)%(LoginFiles.Filename)%(LoginFiles.Extension)</RelativePath>
|
||||
<RelativePath>wwwroot/login/%(LoginFiles.RecursiveDir)%(LoginFiles.Filename)%(LoginFiles.Extension)</RelativePath>
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
|
||||
</ResolvedFileToPublish>
|
||||
@ -105,7 +105,7 @@
|
||||
|
||||
<Target Name="Prepare static and login pages" AfterTargets="Build" Condition="$(Configuration) == 'Debug'">
|
||||
<Copy SourceFiles="@(StaticFiles)" DestinationFolder="$(OutputPath)/wwwroot/%(RecursiveDir)" />
|
||||
<Copy SourceFiles="@(LoginFiles)" DestinationFolder="$(OutputPath)/wwwroot/%(RecursiveDir)" />
|
||||
<Copy SourceFiles="@(LoginFiles)" DestinationFolder="$(OutputPath)/wwwroot/login/%(RecursiveDir)" />
|
||||
</Target>
|
||||
|
||||
<Target Name="Symlink views to output - Linux" AfterTargets="Build" Condition="$(Configuration) == 'Debug' And $(OS) == 'Unix'">
|
||||
|
@ -199,6 +199,7 @@ namespace Kyoo
|
||||
|
||||
FileExtensionContentTypeProvider contentTypeProvider = new();
|
||||
contentTypeProvider.Mappings[".data"] = "application/octet-stream";
|
||||
app.UseDefaultFiles();
|
||||
app.UseStaticFiles(new StaticFileOptions
|
||||
{
|
||||
ContentTypeProvider = contentTypeProvider,
|
||||
|
@ -12,7 +12,6 @@ using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.StaticFiles;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using SignInResult = Microsoft.AspNetCore.Identity.SignInResult;
|
||||
|
||||
@ -47,29 +46,8 @@ namespace Kyoo.Api
|
||||
[FromForm(Name = "picture")]
|
||||
public IFormFile Picture { get; set; }
|
||||
}
|
||||
|
||||
[ApiController]
|
||||
public class AccountUiController : Controller
|
||||
{
|
||||
[HttpGet("login")]
|
||||
public IActionResult Index()
|
||||
{
|
||||
return new PhysicalFileResult(Path.GetFullPath("login/login.html"), "text/html");
|
||||
}
|
||||
|
||||
[HttpGet("login/{*file}")]
|
||||
public IActionResult Index(string file)
|
||||
{
|
||||
string path = Path.Combine(Path.GetFullPath("login/"), file);
|
||||
if (!System.IO.File.Exists(path))
|
||||
return NotFound();
|
||||
FileExtensionContentTypeProvider provider = new FileExtensionContentTypeProvider();
|
||||
if (!provider.TryGetContentType(path, out string contentType))
|
||||
contentType = "text/plain";
|
||||
return new PhysicalFileResult(path, contentType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Route("api/[controller]")]
|
||||
[ApiController]
|
||||
public class AccountController : Controller, IProfileService
|
||||
@ -100,7 +78,7 @@ namespace Kyoo.Api
|
||||
return BadRequest(new[] {new {code = "username", description = "Username must be at least 4 characters."}});
|
||||
if (!new EmailAddressAttribute().IsValid(user.Email))
|
||||
return BadRequest(new[] {new {code = "email", description = "Email must be valid."}});
|
||||
User account = new User {UserName = user.Username, Email = user.Email};
|
||||
User account = new() {UserName = user.Username, Email = user.Email};
|
||||
IdentityResult result = await _userManager.CreateAsync(account, user.Password);
|
||||
if (!result.Succeeded)
|
||||
return BadRequest(result.Errors);
|
||||
@ -151,7 +129,7 @@ namespace Kyoo.Api
|
||||
User user = await _userManager.GetUserAsync(context.Subject);
|
||||
if (user != null)
|
||||
{
|
||||
List<Claim> claims = new List<Claim>
|
||||
List<Claim> claims = new()
|
||||
{
|
||||
new Claim("email", user.Email),
|
||||
new Claim("username", user.UserName),
|
||||
@ -207,6 +185,7 @@ namespace Kyoo.Api
|
||||
[HttpGet("default-permissions")]
|
||||
public ActionResult<IEnumerable<string>> GetDefaultPermissions()
|
||||
{
|
||||
return new List<string>();
|
||||
return _configuration.GetValue<string>("defaultPermissions").Split(",");
|
||||
}
|
||||
}
|
||||
|
@ -21,6 +21,11 @@
|
||||
}
|
||||
},
|
||||
|
||||
"permissions": {
|
||||
"default": "read,play,write,admin",
|
||||
"newUser": "read,play,write,admin"
|
||||
},
|
||||
|
||||
"parallelTasks": "1",
|
||||
|
||||
"scheduledTasks": {
|
||||
@ -35,8 +40,6 @@
|
||||
"providerPath": "providers",
|
||||
"profilePicturePath": "users/",
|
||||
"plugins": "plugins/",
|
||||
"defaultPermissions": "read,play,write,admin",
|
||||
"newUserPermissions": "read,play,write,admin",
|
||||
"regex": "(?:\\/(?<Collection>.*?))?\\/(?<Show>.*?)(?: \\(\\d+\\))?\\/\\k<Show>(?: \\(\\d+\\))?(?:(?: S(?<Season>\\d+)E(?<Episode>\\d+))| (?<Absolute>\\d+))?.*$",
|
||||
"subtitleRegex": "^(?<Episode>.*)\\.(?<Language>\\w{1,3})\\.(?<Default>default\\.)?(?<Forced>forced\\.)?.*$"
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user