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