diff options
Diffstat (limited to 'Controllers')
| -rw-r--r-- | Controllers/ApiFeedController.cs | 1 | ||||
| -rw-r--r-- | Controllers/ApiMediaController.cs | 1 | ||||
| -rw-r--r-- | Controllers/ApiTagController.cs | 1 | ||||
| -rw-r--r-- | Controllers/LoginController.cs | 49 | ||||
| -rw-r--r-- | Controllers/MediaController.cs | 1 |
5 files changed, 0 insertions, 53 deletions
diff --git a/Controllers/ApiFeedController.cs b/Controllers/ApiFeedController.cs index 068cc17..fa8550d 100644 --- a/Controllers/ApiFeedController.cs +++ b/Controllers/ApiFeedController.cs @@ -7,7 +7,6 @@ using Microsoft.EntityFrameworkCore; namespace HyperBooru.Controllers; [ApiController] -[Authorize] [Route("/api/feed")] public class ApiFeedController : Controller { private IFeedService feedService; diff --git a/Controllers/ApiMediaController.cs b/Controllers/ApiMediaController.cs index bb6c81e..f1d466c 100644 --- a/Controllers/ApiMediaController.cs +++ b/Controllers/ApiMediaController.cs @@ -9,7 +9,6 @@ using System.Text.Json; namespace HyperBooru.Controllers; [ApiController] -[Authorize] [Route("/api/media")] public class ApiMediaController : Controller { private IDbContextFactory<HBContext> dbFactory; diff --git a/Controllers/ApiTagController.cs b/Controllers/ApiTagController.cs index d1e49ee..98830bc 100644 --- a/Controllers/ApiTagController.cs +++ b/Controllers/ApiTagController.cs @@ -6,7 +6,6 @@ using Microsoft.EntityFrameworkCore; namespace HyperBooru.Controllers; [ApiController] -[Authorize] [Route("/api/tag")] public class ApiTagController : Controller { private IDbContextFactory<HBContext> dbFactory; diff --git a/Controllers/LoginController.cs b/Controllers/LoginController.cs deleted file mode 100644 index c93f0d5..0000000 --- a/Controllers/LoginController.cs +++ /dev/null @@ -1,49 +0,0 @@ -using HyperBooru.Services; -using Microsoft.AspNetCore.Authentication; -using Microsoft.AspNetCore.Authentication.Cookies; -using Microsoft.AspNetCore.Mvc; -using System.Security.Claims; - -namespace HyperBooru.Controllers; - -[ApiController] -[Route("/")] -public class LoginController : Controller { - private IHttpContextAccessor httpContextAccessor; - - public LoginController(IHttpContextAccessor httpContextAccessor) => - this.httpContextAccessor = httpContextAccessor; - - [HttpPost("Login")] - public async Task<IActionResult> Login( - [FromForm] string username, - [FromForm] string password, - HBContext db) { - - var user = db.Users.FirstOrDefault(u => u.Username == username); - if(user is null) - return StatusCode(403); - - var hash = UserService.HashPassword(password); - if(hash != user.PasswordHash) - return StatusCode(403); - - var claims = new Claim[] { - new Claim(ClaimTypes.Name, user.Username), - new Claim("ObjectId", user.ObjectId.ToString()) - }; - - var claimsIdentity = new ClaimsIdentity( - claims, - CookieAuthenticationDefaults.AuthenticationScheme); - - var claimsPrincipal = new ClaimsPrincipal(claimsIdentity); - - await httpContextAccessor.HttpContext!.SignInAsync(claimsPrincipal); - return Ok(); - } - - [HttpPost("Logout")] - public async Task Logout() => - await httpContextAccessor.HttpContext!.SignOutAsync(); -} diff --git a/Controllers/MediaController.cs b/Controllers/MediaController.cs index 248765a..9a816e6 100644 --- a/Controllers/MediaController.cs +++ b/Controllers/MediaController.cs @@ -8,7 +8,6 @@ using Microsoft.EntityFrameworkCore; namespace HyperBooru.Controllers; [ApiController] -[Authorize] [Route("/media")] public class MediaController : Controller { private IHttpContextAccessor httpContextAccessor; |
