From dc9aa108a13fb3755aac3ca33e8f51219ddbab30 Mon Sep 17 00:00:00 2001 From: Claude Code Date: Fri, 26 Jun 2026 17:00:03 +0900 Subject: [PATCH] =?UTF-8?q?=EC=9E=91=EC=97=85=EC=A4=91:=20W4=20=EA=B4=80?= =?UTF-8?q?=EB=A6=AC=EC=9E=90=20=EB=A1=9C=EA=B7=B8=EC=9D=B8=20=EA=B5=AC?= =?UTF-8?q?=ED=98=84=20(BCrypt=20=EC=9D=B8=EC=A6=9D)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Login.razor: BCrypt 기반 실제 비밀번호 검증 - TaxBaik.Admin.csproj: BCrypt.Net-Next 패키지 추가 - HttpContext.SignInAsync로 쿠키 인증 처리 주의: 아직 런타임 이슈 수정 필요 Co-Authored-By: Claude Haiku 4.5 --- TaxBaik.Admin/Components/Pages/Login.razor | 53 +++++++++++++++++++++- TaxBaik.Admin/TaxBaik.Admin.csproj | 1 + 2 files changed, 52 insertions(+), 2 deletions(-) diff --git a/TaxBaik.Admin/Components/Pages/Login.razor b/TaxBaik.Admin/Components/Pages/Login.razor index b2d041e..e1c30bf 100644 --- a/TaxBaik.Admin/Components/Pages/Login.razor +++ b/TaxBaik.Admin/Components/Pages/Login.razor @@ -29,16 +29,65 @@ +@using Microsoft.AspNetCore.Authentication +@using System.Security.Claims +@using TaxBaik.Domain.Interfaces + @code { private MudForm form; private bool isFormValid = false; private string errorMessage = ""; - private LoginModel model = new(); + private bool isLoading = false; + + [Inject] + private IAdminUserRepository AdminUserRepository { get; set; } + + [Inject] + private NavigationManager NavigationManager { get; set; } + + [Inject] + private HttpContextAccessor HttpContextAccessor { get; set; } private async Task HandleLogin() { - errorMessage = "로그인 기능은 준비 중입니다."; + if (!isFormValid) return; + isLoading = true; + errorMessage = ""; + + try + { + var user = await AdminUserRepository.GetByUsernameAsync(model.Username); + if (user == null || !BCrypt.Net.BCrypt.Verify(model.Password, user.PasswordHash)) + { + errorMessage = "사용자명 또는 비밀번호가 올바르지 않습니다."; + isLoading = false; + return; + } + + var claims = new List + { + new Claim(ClaimTypes.NameIdentifier, user.Id.ToString()), + new Claim(ClaimTypes.Name, user.Username) + }; + var claimsIdentity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme); + var authProperties = new AuthenticationProperties { IsPersistent = true }; + + await HttpContextAccessor.HttpContext.SignInAsync( + CookieAuthenticationDefaults.AuthenticationScheme, + new ClaimsPrincipal(claimsIdentity), + authProperties); + + NavigationManager.NavigateTo("/taxbaik/admin/dashboard"); + } + catch (Exception ex) + { + errorMessage = $"로그인 중 오류: {ex.Message}"; + } + finally + { + isLoading = false; + } } private class LoginModel diff --git a/TaxBaik.Admin/TaxBaik.Admin.csproj b/TaxBaik.Admin/TaxBaik.Admin.csproj index 9f19aed..8f8c88c 100644 --- a/TaxBaik.Admin/TaxBaik.Admin.csproj +++ b/TaxBaik.Admin/TaxBaik.Admin.csproj @@ -13,6 +13,7 @@ +