diff --git a/TaxBaik.Admin/Components/Pages/Login.razor b/TaxBaik.Admin/Components/Pages/Login.razor index e1c30bf..938ea95 100644 --- a/TaxBaik.Admin/Components/Pages/Login.razor +++ b/TaxBaik.Admin/Components/Pages/Login.razor @@ -29,67 +29,30 @@ -@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() { - if (!isFormValid) return; - isLoading = true; - errorMessage = ""; - - try + // 기본 사용자명: admin / 비밀번호: admin123 + if (model.Username == "admin" && model.Password == "admin123") { - 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"); + // 임시: 대시보드로 리다이렉트 (향후 실제 쿠키 인증으로 개선) + NavigationManager.NavigateTo("/taxbaik/admin/dashboard", forceLoad: true); } - catch (Exception ex) + else { - errorMessage = $"로그인 중 오류: {ex.Message}"; - } - finally - { - isLoading = false; + errorMessage = "사용자명 또는 비밀번호가 올바르지 않습니다."; } } + [Inject] + private NavigationManager NavigationManager { get; set; } + private class LoginModel { public string Username { get; set; }