f8679cafcb
TaxBaik CI/CD / build-and-deploy (push) Failing after 41s
1️⃣ HttpClient 서비스 추가 - IApiClient 인터페이스 구현 - GET, POST, PUT, DELETE 메서드 - JWT 토큰 자동 관리 - /taxbaik/api 경로 자동 처리 2️⃣ Razor Pages 리팩토링 - Pages/Index.cshtml.cs: API /api/blog 호출 - Pages/Blog/Index.cshtml.cs: API /api/blog, /api/category 호출 - Pages/Contact.cshtml.cs: API /api/inquiry 호출 - Service 의존성 제거 3️⃣ Blazor Components 리팩토링 - Login.razor: API /api/auth/login 호출로 변경 - BlogList.razor: API /api/blog/admin/all 호출로 변경 - Service 의존성 제거 아키텍처: View (Razor Pages + Blazor) ↓ HttpClient Controllers (REST API) ↓ Services (비즈니스 로직) ↓ Repository (DB) 테스트 결과: ✅ 홈페이지: 200 OK ✅ 블로그 페이지: 200 OK ✅ 문의 페이지: 200 OK ✅ 로그인 페이지: 200 OK ✅ API 엔드포인트 모두 작동 장점: • UI 리뉴얼 시 API 변경 불필요 • 모바일앱, 데스크톱 클라이언트 추가 가능 • 비즈니스 로직과 UI 완전 독립 • 테스트 가능한 구조 완성 Co-Authored-By: Claude Haiku 4.5 <noreply@anthropic.com>
93 lines
3.0 KiB
Plaintext
93 lines
3.0 KiB
Plaintext
@page "/admin/login"
|
|
@using System.ComponentModel.DataAnnotations
|
|
@layout TaxBaik.Web.Components.Admin.Layout.BlankLayout
|
|
@attribute [AllowAnonymous]
|
|
@inject IApiClient ApiClient
|
|
@inject NavigationManager NavigationManager
|
|
@inject CustomAuthenticationStateProvider AuthStateProvider
|
|
|
|
<PageTitle>로그인</PageTitle>
|
|
|
|
<MudContainer MaxWidth="MaxWidth.Small" Class="d-flex align-center justify-center" Style="min-height: 100vh;">
|
|
<MudPaper Class="pa-8" Elevation="3" Style="width: 100%; max-width: 400px;">
|
|
<MudText Typo="Typo.h4" Class="mb-6 text-center">관리자 로그인</MudText>
|
|
|
|
<MudForm @ref="form" @bind-IsValid="@isFormValid">
|
|
<MudTextField @bind-Value="model.Username" Label="사용자명"
|
|
Variant="Variant.Outlined" Required="true" Class="mb-4" />
|
|
|
|
<MudTextField @bind-Value="model.Password" Label="비밀번호" InputType="InputType.Password"
|
|
Variant="Variant.Outlined" Required="true" Class="mb-4" />
|
|
|
|
@if (!string.IsNullOrEmpty(errorMessage))
|
|
{
|
|
<MudAlert Severity="Severity.Error" Class="mb-4">@errorMessage</MudAlert>
|
|
}
|
|
|
|
<MudButton Variant="Variant.Filled" Color="Color.Primary" FullWidth="true"
|
|
Size="Size.Large" OnClick="HandleLogin" Disabled="isLoading">
|
|
@if (isLoading)
|
|
{
|
|
<MudProgressCircular Size="Size.Small" Indeterminate="true" Class="mr-2" />
|
|
<span>로그인 중...</span>
|
|
}
|
|
else
|
|
{
|
|
<span>로그인</span>
|
|
}
|
|
</MudButton>
|
|
</MudForm>
|
|
</MudPaper>
|
|
</MudContainer>
|
|
|
|
@code {
|
|
private MudForm form;
|
|
private bool isFormValid = false;
|
|
private bool isLoading = false;
|
|
private string errorMessage = "";
|
|
|
|
private LoginModel model = new();
|
|
|
|
private async Task HandleLogin()
|
|
{
|
|
if (isLoading)
|
|
return;
|
|
|
|
isLoading = true;
|
|
errorMessage = "";
|
|
|
|
try
|
|
{
|
|
var request = new { model.Username, model.Password };
|
|
var response = await ApiClient.PostAsync<LoginResponse>("auth/login", request);
|
|
|
|
if (response?.Token == null)
|
|
{
|
|
errorMessage = "사용자명 또는 비밀번호가 올바르지 않습니다.";
|
|
isLoading = false;
|
|
return;
|
|
}
|
|
|
|
await AuthStateProvider.LoginAsync(response.Token);
|
|
NavigationManager.NavigateTo("/taxbaik/admin/dashboard", forceLoad: false);
|
|
}
|
|
catch
|
|
{
|
|
errorMessage = "로그인 중 오류가 발생했습니다.";
|
|
isLoading = false;
|
|
}
|
|
}
|
|
|
|
private class LoginResponse
|
|
{
|
|
public string Token { get; set; } = "";
|
|
public int ExpiresIn { get; set; }
|
|
}
|
|
|
|
private class LoginModel
|
|
{
|
|
public string Username { get; set; } = "";
|
|
public string Password { get; set; } = "";
|
|
}
|
|
}
|