forked from AcaMate/AcaMate_Web
[✨] 학원용 입장페이지 작성
1. /am/... 도메인 생성 2. /am/intro 페이지 생성 3. 메인 레이아웃 상황 따라 변경 4. 로그인 정보 받아오는 로직 변경 중 4.1. 유저 정보에 대한 JSON은 받아왔으나 이를 저장하는 로직 구현 중 4.2. 로그인 정보를 받아오는 로직을 어디서 구현해야 할 지 고민 하는 중
This commit is contained in:
parent
05e8fcd0b0
commit
c371700e78
|
@ -38,6 +38,7 @@ builder.Services.AddScoped<StorageService>();
|
|||
// builder.Services.AddRazorPages();
|
||||
// builder.Services.AddServerSideBlazor();
|
||||
builder.Services.AddScoped<LoadingService>();
|
||||
builder.Services.AddScoped<UserService>();
|
||||
|
||||
|
||||
await builder.Build().RunAsync();
|
||||
|
|
|
@ -1,30 +1,39 @@
|
|||
@inherits LayoutComponentBase
|
||||
@inherits LayoutComponentBase
|
||||
@implements IDisposable
|
||||
|
||||
<div class="min-h-screen flex flex-col bg-gray-50 text-gray-900">
|
||||
|
||||
<!-- Top 영역 -->
|
||||
@* <TopBanner /> *@
|
||||
|
||||
@if (!isHidePrjTop)
|
||||
|
||||
@if(isAcademy)
|
||||
{
|
||||
<TopProjectNav />
|
||||
<div class="flex flex-1 flex-col md:flex-row">
|
||||
<div class="hidden md:block w-64 bg-white shadow-lg border-r border-gray-200 fixed top-0 bottom-0">
|
||||
<LeftSideAcademy />
|
||||
</div>
|
||||
|
||||
<div class="flex flex-1 flex-col md:ml-64">
|
||||
<div class="fixed top-0 right-0 left-64 z-10">
|
||||
<TopNavAcademy />
|
||||
</div>
|
||||
<div class="flex-1 mt-16">
|
||||
@Body
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- 본문 영역 -->
|
||||
<div class="flex flex-1 flex-col md:flex-row">
|
||||
|
||||
@* <!-- 사이드 메뉴 --> *@
|
||||
@* <div class="hidden md:block md:w-64 bg-white shadow"> *@
|
||||
@* <SideNav /> *@
|
||||
@* </div> *@
|
||||
|
||||
else
|
||||
{
|
||||
@if (!isHidePrjTop)
|
||||
{
|
||||
<TopProjectNav />
|
||||
}
|
||||
<!-- 본문 컨텐츠 -->
|
||||
@* <main class="flex-1 p-4 sm:p-6 md:p-8"> *@
|
||||
<main class="flex-1 w-full w-max-960 mx-auto">
|
||||
@Body
|
||||
</main>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- 플로팅 버튼 -->
|
||||
<FloatingButton />
|
||||
|
|
|
@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components;
|
|||
using Microsoft.AspNetCore.Components.Routing;
|
||||
|
||||
using Front.Program.Views.Project;
|
||||
using Front.Program.Views.Academy;
|
||||
using Front.Program.Services;
|
||||
|
||||
namespace Front.Program.Layout;
|
||||
|
@ -22,6 +23,7 @@ public partial class MainLayout : LayoutComponentBase, IDisposable
|
|||
|
||||
// 경로의 끝 부분
|
||||
protected bool isHidePrjTop => Navigation.ToBaseRelativePath(Navigation.Uri).EndsWith("auth", StringComparison.OrdinalIgnoreCase);
|
||||
protected bool isAcademy => Navigation.ToBaseRelativePath(Navigation.Uri).StartsWith("am", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
|
|
133
Program/Services/UserService.cs
Normal file
133
Program/Services/UserService.cs
Normal file
|
@ -0,0 +1,133 @@
|
|||
using System.Text.Json;
|
||||
using Microsoft.JSInterop;
|
||||
|
||||
namespace Front.Program.Services;
|
||||
|
||||
public class UserService
|
||||
{
|
||||
private readonly StorageService _storageService;
|
||||
private readonly SecureService _secureService;
|
||||
private readonly IJSRuntime _js;
|
||||
private readonly ILogger<UserService> _logger;
|
||||
|
||||
public UserService(
|
||||
StorageService storageService,
|
||||
SecureService secureService,
|
||||
IJSRuntime js,
|
||||
ILogger<UserService> logger)
|
||||
{
|
||||
_storageService = storageService;
|
||||
_secureService = secureService;
|
||||
_js = js;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
public class UserData
|
||||
{
|
||||
public string Uid { get; set; } = string.Empty;
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public DateTime? Birth { get; set; }
|
||||
public string Type { get; set; } = string.Empty;
|
||||
public string? DeviceId { get; set; }
|
||||
public bool AutoLoginYn { get; set; }
|
||||
public DateTime LoginDate { get; set; }
|
||||
public string? PushToken { get; set; }
|
||||
}
|
||||
|
||||
public async Task<(bool success, UserData? userData)> GetUserData()
|
||||
{
|
||||
try
|
||||
{
|
||||
// 1. 먼저 저장된 데이터 확인
|
||||
var encryptedUserData = await _storageService.GetItemAsync("USER_DATA");
|
||||
if (!string.IsNullOrEmpty(encryptedUserData))
|
||||
{
|
||||
try
|
||||
{
|
||||
var decryptedUserData = await _secureService.DecryptAsync(encryptedUserData);
|
||||
var userData = JsonSerializer.Deserialize<UserData>(decryptedUserData);
|
||||
if (userData != null && !string.IsNullOrEmpty(userData.Name))
|
||||
{
|
||||
_logger.LogInformation("저장된 사용자 데이터 로드 성공");
|
||||
return (true, userData);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogWarning($"저장된 사용자 데이터 복호화 실패: {ex.Message}");
|
||||
await _storageService.RemoveItemAsync("USER_DATA");
|
||||
}
|
||||
}
|
||||
|
||||
// 2. API 호출
|
||||
var headerValue = await _storageService.GetItemAsync("Web_AM_Connect_Key");
|
||||
if (string.IsNullOrEmpty(headerValue))
|
||||
{
|
||||
_logger.LogWarning("연결 키가 없습니다");
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
_logger.LogInformation("세션 API 호출 시작");
|
||||
var response = await _js.InvokeAsync<JsonElement>("fetchWithHeaderAndReturnUrl",
|
||||
"/api/v1/in/user/auth/session",
|
||||
"GET",
|
||||
"Web_AM_Connect_Key",
|
||||
headerValue);
|
||||
|
||||
if (response.TryGetProperty("data", out var dataElement))
|
||||
{
|
||||
try
|
||||
{
|
||||
// 전체 데이터 암호화 저장
|
||||
var userDataJson = dataElement.ToString();
|
||||
var userData = JsonSerializer.Deserialize<UserData>(userDataJson);
|
||||
|
||||
if (userData != null && !string.IsNullOrEmpty(userData.Name))
|
||||
{
|
||||
var encryptedData = await _secureService.EncryptAsync(userDataJson);
|
||||
await _storageService.SetItemAsync("USER_DATA", encryptedData);
|
||||
await _storageService.SetItemAsync("Web_AM_Connect_Key", headerValue);
|
||||
|
||||
_logger.LogInformation($"사용자 데이터 저장 성공: {userData.Name}");
|
||||
return (true, userData);
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.LogWarning("사용자 데이터에 필수 정보가 없습니다");
|
||||
return (false, null);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"사용자 데이터 처리 중 오류: {ex.Message}");
|
||||
return (false, null);
|
||||
}
|
||||
}
|
||||
|
||||
_logger.LogWarning("사용자 데이터를 찾을 수 없습니다");
|
||||
return (false, null);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"사용자 데이터 조회 중 오류: {ex.Message}");
|
||||
return (false, null);
|
||||
}
|
||||
}
|
||||
|
||||
public async Task<bool> ClearUserData()
|
||||
{
|
||||
try
|
||||
{
|
||||
await _storageService.RemoveItemAsync("USER_DATA");
|
||||
await _storageService.RemoveItemAsync("USER");
|
||||
await _storageService.RemoveItemAsync("Web_AM_Connect_Key");
|
||||
_logger.LogInformation("사용자 데이터 삭제 성공");
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError($"사용자 데이터 삭제 중 오류: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
30
Program/Views/Academy/AcademyIntro.razor
Normal file
30
Program/Views/Academy/AcademyIntro.razor
Normal file
|
@ -0,0 +1,30 @@
|
|||
@page "/am/intro"
|
||||
|
||||
<div class="relative flex size-full min-h-screen flex-col bg-white group/design-root overflow-x-hidden" style='font-family: "Public Sans", "Noto Sans", sans-serif;'>
|
||||
<div class="layout-container flex h-full grow flex-col">
|
||||
<div class="px-40 flex flex-1 justify-center py-5">
|
||||
<div class="layout-content-container flex flex-col max-w-[960px] flex-1">
|
||||
<div class="w-full" style="height: 100px;"></div>
|
||||
<div class="container">
|
||||
<div class="px-4 py-3">
|
||||
<div
|
||||
class="w-full bg-center bg-no-repeat bg-cover flex flex-col justify-end overflow-hidden bg-white rounded-xl min-h-[218px]"
|
||||
style='background-image: url("https://lh3.googleusercontent.com/aida-public/AB6AXuBDQ6ItFmMNXPyz0TZ_MJfBxzunRwfPEo5gf23eHqM80NCcy7sZgfhQgiCTCOX3u8_Ecpx5oRkoRsGCPzZY4Mciglrr0-n7SqyJnM6XJgCJ4sy9a6dSP5AXQVMpa3StypgUdTxSWkIFH1QQddb_7HOqqQazEwH7x_dSKrr-FHUF1EfvLihJD210rH0QjgBxdaEhHpKsJVUEa_OrRZ30VF5yADD9xDz05g_bwHcGOPXlWnVERJldx6hc-eEFHwR483kVmiSSRODPv4XC");'
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class="text-[#111518] tracking-light text-2xl font-bold leading-tight px-4 text-center pb-2 pt-5">학원을 위한 통합 플랫폼</h3>
|
||||
<div class="flex px-4 py-3 justify-center">
|
||||
<button
|
||||
class="flex min-w-[84px] max-w-[480px] cursor-pointer items-center justify-center overflow-hidden rounded-xl h-12 px-5 bg-[#1990e5] text-white text-base font-bold leading-normal tracking-[0.015em]"
|
||||
>
|
||||
<span class="truncate">시작하기</span>
|
||||
</button>
|
||||
</div>
|
||||
<div class="w-full" style="height: 100px;"></div>
|
||||
<p class="text-[#637888] text-sm font-normal leading-normal pb-3 pt-1 px-4 text-center">Terms of Service · Privacy Policy · Contact Us</p>
|
||||
<p class="text-[#637888] text-sm font-normal leading-normal pb-3 pt-1 px-4 text-center">© 2024 AcaMate. All rights reserved.</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
7
Program/Views/Academy/AcademyIntro.razor.cs
Normal file
7
Program/Views/Academy/AcademyIntro.razor.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Front.Program.Views.Academy;
|
||||
|
||||
public partial class AcademyIntro : ComponentBase
|
||||
{
|
||||
}
|
70
Program/Views/Academy/LeftSideAcademy.razor
Normal file
70
Program/Views/Academy/LeftSideAcademy.razor
Normal file
|
@ -0,0 +1,70 @@
|
|||
<div class="h-[72px] p-4 border-b border-gray-200 flex items-center">
|
||||
<div class="flex items-center gap-3">
|
||||
<div class="w-10 h-10 rounded-full bg-gray-200 overflow-hidden">
|
||||
<img src="Resources/Images/Logo/Crystal_Icon.png" alt="프로필" class="w-full h-full object-cover" />
|
||||
</div>
|
||||
<div>
|
||||
<!-- 회원 이름이 오는 곳 -->
|
||||
<div class="text-gray-900 text-base font-medium">AcaMate</div>
|
||||
<!-- 회원 유형이 올 곳 -->
|
||||
<p class="text-gray-600 text-sm">Parent</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 메뉴 섹션 -->
|
||||
<nav class="flex-1 p-4 space-y-2 ">
|
||||
<a href="/academy/children" class="flex items-center gap-3 px-3 py-2 rounded-lg bg-gray-100">
|
||||
<div class="text-gray-700">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256">
|
||||
<path d="M164.47,195.63a8,8,0,0,1-6.7,12.37H10.23a8,8,0,0,1-6.7-12.37,95.83,95.83,0,0,1,47.22-37.71,60,60,0,1,1,66.5,0A95.83,95.83,0,0,1,164.47,195.63Z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="text-gray-700 text-sm font-medium">My Children</span>
|
||||
</a>
|
||||
|
||||
<a href="/academy/attendance" class="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-gray-100">
|
||||
<div class="text-gray-700">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256">
|
||||
<path d="M208,32H184V24a8,8,0,0,0-16,0v8H88V24a8,8,0,0,0-16,0v8H48A16,16,0,0,0,32,48V208a16,16,0,0,0,16,16H208a16,16,0,0,0,16-16V48A16,16,0,0,0,208,32Z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="text-gray-700 text-sm font-medium">Attendance</span>
|
||||
</a>
|
||||
|
||||
<a href="/academy/announcements" class="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-gray-100">
|
||||
<div class="text-gray-700">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256">
|
||||
<path d="M240,120a48.05,48.05,0,0,0-48-48H152.2c-2.91-.17-53.62-3.74-101.91-44.24A16,16,0,0,0,24,40V200a16,16,0,0,0,26.29,12.25c37.77-31.68,77-40.76,93.71-43.3v31.72A16,16,0,0,0,151.12,214l11,7.33A16,16,0,0,0,186.5,212l11.77-44.36A48.07,48.07,0,0,0,240,120Z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="text-gray-700 text-sm font-medium">Announcements</span>
|
||||
</a>
|
||||
|
||||
<a href="/academy/messages" class="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-gray-100">
|
||||
<div class="text-gray-700">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256">
|
||||
<path d="M140,128a12,12,0,1,1-12-12A12,12,0,0,1,140,128ZM84,116a12,12,0,1,0,12,12A12,12,0,0,0,84,116Zm88,0a12,12,0,1,0,12,12A12,12,0,0,0,172,116Z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="text-gray-700 text-sm font-medium">Messages</span>
|
||||
</a>
|
||||
|
||||
<a href="/academy/bus-tracking" class="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-gray-100">
|
||||
<div class="text-gray-700">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256">
|
||||
<path d="M184,32H72A32,32,0,0,0,40,64V208a16,16,0,0,0,16,16H80a16,16,0,0,0,16-16V192h64v16a16,16,0,0,0,16,16h24a16,16,0,0,0,16-16V64A32,32,0,0,0,184,32Z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="text-gray-700 text-sm font-medium">Bus Tracking</span>
|
||||
</a>
|
||||
|
||||
<a href="/academy/settings" class="flex items-center gap-3 px-3 py-2 rounded-lg hover:bg-gray-100">
|
||||
<div class="text-gray-700">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 256 256">
|
||||
<path d="M128,80a48,48,0,1,0,48,48A48.05,48.05,0,0,0,128,80Zm0,80a32,32,0,1,1,32-32A32,32,0,0,1,128,160Z"></path>
|
||||
</svg>
|
||||
</div>
|
||||
<span class="text-gray-700 text-sm font-medium">Settings</span>
|
||||
</a>
|
||||
</nav>
|
7
Program/Views/Academy/LeftSideAcademy.razor.cs
Normal file
7
Program/Views/Academy/LeftSideAcademy.razor.cs
Normal file
|
@ -0,0 +1,7 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Front.Program.Views.Academy;
|
||||
|
||||
public partial class LeftSideAcademy : ComponentBase
|
||||
{
|
||||
}
|
18
Program/Views/Academy/TopNavAcademy.razor
Normal file
18
Program/Views/Academy/TopNavAcademy.razor
Normal file
|
@ -0,0 +1,18 @@
|
|||
<div class="flex items-center justify-between whitespace-nowrap border-b border-solid border-b-[#f0f2f5] h-[72px] bg-white">
|
||||
<div class="flex items-center gap-4 text-[#111418] ml-4">
|
||||
<div class="w-10 h-10 rounded-full bg-gray-200 overflow-hidden">
|
||||
<img src="/logo.png" alt="Icon" class="w-full h-full object-cover">
|
||||
</div>
|
||||
<h2 class="hidden md:block text-text-title text-lg font-bold leading-tight tracking-[-0.015em]">AcaMate</h2>
|
||||
</div>
|
||||
|
||||
<div class="hidden md:flex flex-1 justify-end gap-8">
|
||||
<div class="flex flex-1 justify-end gap-8">
|
||||
<div class="flex items-center gap-9">
|
||||
<a class="text-text-title font-medium leading-normal hover:text-blue-600" href="/about">About</a>
|
||||
<a class="text-text-title font-medium leading-normal hover:text-blue-600" href="/join">Join</a>
|
||||
<a class="text-text-title font-medium leading-normal hover:text-blue-600" href="/new">What's New</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
6
Program/Views/Academy/TopNavAcademy.razor.cs
Normal file
6
Program/Views/Academy/TopNavAcademy.razor.cs
Normal file
|
@ -0,0 +1,6 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
|
||||
namespace Front.Program.Views.Academy;
|
||||
|
||||
public partial class TopNavAcademy : ComponentBase
|
||||
{}
|
|
@ -167,8 +167,8 @@
|
|||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<footer class="flex justify-center border-t border-text-border">
|
||||
|
||||
<div class="flex justify-center border-t border-text-border">
|
||||
<div class="flex max-w-[960px] flex-1 flex-col">
|
||||
<footer class="flex flex-col gap-6 px-5 py-10 text-center container">
|
||||
<div class="flex flex-wrap items-center justify-center gap-6 xs:flex-row xs:justify-around">
|
||||
|
@ -179,6 +179,19 @@
|
|||
<p class="text-[#60758a] text-base font-normal leading-normal">© 2024 AcaMate. All rights reserved.</p>
|
||||
</footer>
|
||||
</div>
|
||||
</footer>
|
||||
</div>
|
||||
|
||||
@* <footer class="flex justify-center border-t border-text-border"> *@
|
||||
@* <div class="flex max-w-[960px] flex-1 flex-col"> *@
|
||||
@* <footer class="flex flex-col gap-6 px-5 py-10 text-center container"> *@
|
||||
@* <div class="flex flex-wrap items-center justify-center gap-6 xs:flex-row xs:justify-around"> *@
|
||||
@* <a class="text-[#60758a] text-base font-normal leading-normal min-w-40" href="#">Terms of Service</a> *@
|
||||
@* <a class="text-[#60758a] text-base font-normal leading-normal min-w-40" href="#">Privacy Policy</a> *@
|
||||
@* <a class="text-[#60758a] text-base font-normal leading-normal min-w-40" href="#">Contact Us</a> *@
|
||||
@* </div> *@
|
||||
@* <p class="text-[#60758a] text-base font-normal leading-normal">© 2024 AcaMate. All rights reserved.</p> *@
|
||||
@* </footer> *@
|
||||
@* </div> *@
|
||||
@* </footer> *@
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
@page "/auth"
|
||||
@page "/academy/auth"
|
||||
@page "/am/auth"
|
||||
|
||||
<div class="flex flex-col items-center justify-center min-h-screen bg-gray-100">
|
||||
<h1 class="text-2xl font-bold mb-4">로그인</h1>
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
<h3>PageIndicator</h3>
|
||||
|
||||
@if (Type == IndicateType.Page)
|
||||
{
|
||||
<div class="fixed top-0 left-0 w-full h-14 bg-black/70 flex items-center justify-center z-50">
|
||||
|
|
|
@ -9,6 +9,6 @@ public partial class RedirectPage : ComponentBase
|
|||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
NavigationManager.NavigateTo("/about",true);
|
||||
NavigationManager.NavigateTo("/am/intro",true);
|
||||
}
|
||||
}
|
|
@ -10,8 +10,7 @@ namespace Front.Program.Views.Project;
|
|||
public partial class TopProjectNav : ComponentBase
|
||||
{
|
||||
[Inject] NavigationManager NavigationManager { get; set; } = default!;
|
||||
[Inject] StorageService StorageService { get; set; } = default!;
|
||||
[Inject] SecureService SecureService { get; set; } = default!;
|
||||
[Inject] UserService UserService { get; set; } = default!;
|
||||
|
||||
[Inject] IJSRuntime JS { get; set; } = default!;
|
||||
|
||||
|
@ -23,110 +22,123 @@ public partial class TopProjectNav : ComponentBase
|
|||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
Console.WriteLine("TopNAV 확인");
|
||||
isLogin = bool.TryParse(await StorageService.GetItemAsync("IsLogin"), out var result) && result;
|
||||
// if (!isLogin && !string.IsNullOrEmpty(UserName)) return;
|
||||
if (!isLogin) return; // && !string.IsNullOrEmpty(UserName)) return;
|
||||
var (success, userData) = await UserService.GetUserData();
|
||||
if (success && userData != null)
|
||||
{
|
||||
Console.WriteLine(userData.Name);
|
||||
UserName = userData.Name;
|
||||
isLogin = true;
|
||||
}
|
||||
// isLogin = bool.TryParse(await StorageService.GetItemAsync("IsLogin"), out var result) && result;
|
||||
// // if (!isLogin && !string.IsNullOrEmpty(UserName)) return;
|
||||
// if (!isLogin) return; // && !string.IsNullOrEmpty(UserName)) return;
|
||||
|
||||
try
|
||||
{
|
||||
var encryptedName = await StorageService.GetItemAsync("USER");
|
||||
Console.WriteLine($"{encryptedName}");
|
||||
if (!string.IsNullOrEmpty(encryptedName))
|
||||
{
|
||||
try
|
||||
{
|
||||
UserName = await SecureService.DecryptAsync(encryptedName);
|
||||
Console.WriteLine($"세션 스토리지에서 가져온 사용자 이름: '{UserName}'");
|
||||
// try
|
||||
// {
|
||||
// var encryptedName = await StorageService.GetItemAsync("USER");
|
||||
// Console.WriteLine($"{encryptedName}");
|
||||
// if (!string.IsNullOrEmpty(encryptedName))
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// UserName = await SecureService.DecryptAsync(encryptedName);
|
||||
// Console.WriteLine($"세션 스토리지에서 가져온 사용자 이름: '{UserName}'");
|
||||
|
||||
return;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"이름 복호화 중 오류 발생: {ex.Message}");
|
||||
await StorageService.RemoveItemAsync("USER");
|
||||
}
|
||||
}
|
||||
// return;
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine($"이름 복호화 중 오류 발생: {ex.Message}");
|
||||
// await StorageService.RemoveItemAsync("USER");
|
||||
// }
|
||||
// }
|
||||
|
||||
// apiSender.js의 함수를 사용하여 연결 키 가져오기
|
||||
var headerValue = await StorageService.GetItemAsync("Web_AM_Connect_Key");
|
||||
Console.WriteLine($"세션 스토리지에서 가져온 헤더 값: '{headerValue}'");
|
||||
// // apiSender.js의 함수를 사용하여 연결 키 가져오기
|
||||
// var headerValue = await StorageService.GetItemAsync("Web_AM_Connect_Key");
|
||||
// Console.WriteLine($"세션 스토리지에서 가져온 헤더 값: '{headerValue}'");
|
||||
|
||||
if (string.IsNullOrEmpty(headerValue))
|
||||
{
|
||||
Console.WriteLine("연결 키가 없습니다");
|
||||
return;
|
||||
}
|
||||
// if (string.IsNullOrEmpty(headerValue))
|
||||
// {
|
||||
// Console.WriteLine("연결 키가 없습니다");
|
||||
// return;
|
||||
// }
|
||||
|
||||
// apiSender.js의 함수를 사용하여 API 호출
|
||||
Console.WriteLine("세션 API 호출 시작");
|
||||
var response = await JS.InvokeAsync<JsonElement>("fetchWithHeaderAndReturnUrl",
|
||||
"/api/v1/in/user/auth/session",
|
||||
"GET",
|
||||
"Web_AM_Connect_Key",
|
||||
headerValue);
|
||||
// // apiSender.js의 함수를 사용하여 API 호출
|
||||
// Console.WriteLine("세션 API 호출 시작");
|
||||
// var response = await JS.InvokeAsync<JsonElement>("fetchWithHeaderAndReturnUrl",
|
||||
// "/api/v1/in/user/auth/session",
|
||||
// "GET",
|
||||
// "Web_AM_Connect_Key",
|
||||
// headerValue);
|
||||
|
||||
Console.WriteLine($"세션 API 응답 타입: {response.ValueKind}");
|
||||
Console.WriteLine($"세션 API 응답 내용: {response}");
|
||||
// Console.WriteLine($"세션 API 응답 타입: {response.ValueKind}");
|
||||
// Console.WriteLine($"세션 API 응답 내용: {response}");
|
||||
|
||||
if (response.ValueKind == JsonValueKind.Null || response.ValueKind == JsonValueKind.Undefined)
|
||||
{
|
||||
Console.WriteLine("응답이 null이거나 undefined입니다");
|
||||
return;
|
||||
}
|
||||
// if (response.ValueKind == JsonValueKind.Null || response.ValueKind == JsonValueKind.Undefined)
|
||||
// {
|
||||
// Console.WriteLine("응답이 null이거나 undefined입니다");
|
||||
// return;
|
||||
// }
|
||||
|
||||
try
|
||||
{
|
||||
if (response.TryGetProperty("status", out var statusElement))
|
||||
{
|
||||
Console.WriteLine($"status 요소 타입: {statusElement.ValueKind}");
|
||||
if (statusElement.TryGetProperty("code", out var codeElement))
|
||||
{
|
||||
var code = codeElement.GetString();
|
||||
Console.WriteLine($"응답 코드: {code}");
|
||||
// try
|
||||
// {
|
||||
// if (response.TryGetProperty("status", out var statusElement))
|
||||
// {
|
||||
// Console.WriteLine($"status 요소 타입: {statusElement.ValueKind}");
|
||||
// if (statusElement.TryGetProperty("code", out var codeElement))
|
||||
// {
|
||||
// var code = codeElement.GetString();
|
||||
// Console.WriteLine($"응답 코드: {code}");
|
||||
|
||||
if (code == "000")
|
||||
{
|
||||
if (response.TryGetProperty("data", out var dataElement))
|
||||
{
|
||||
Console.WriteLine($"data 요소 타입: {dataElement.ValueKind}");
|
||||
if (dataElement.TryGetProperty("name", out var nameElement))
|
||||
{
|
||||
UserName = nameElement.GetString() ?? "이름 없음";
|
||||
isLogin = true;
|
||||
Console.WriteLine($"NM: {UserName}");
|
||||
var encryptedUserName = await SecureService.EncryptAsync(UserName);
|
||||
Console.WriteLine($"NM: {encryptedUserName}");
|
||||
await StorageService.SetItemAsync("USER", encryptedUserName);
|
||||
await StorageService.SetItemAsync("Web_AM_Connect_Key", headerValue);
|
||||
Console.WriteLine($"로그인된 사용자: {UserName}");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (isLogin) {
|
||||
isLogin = false;
|
||||
await StorageService.SetItemAsync("IsLogin","false");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
Console.WriteLine("로그인되지 않은 상태");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"응답 처리 중 오류 발생: {ex.Message}");
|
||||
Console.WriteLine($"응답 처리 스택 트레이스: {ex.StackTrace}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"세션 확인 중 오류 발생: {ex.Message}");
|
||||
Console.WriteLine($"스택 트레이스: {ex.StackTrace}");
|
||||
}
|
||||
// if (code == "000")
|
||||
// {
|
||||
// if (response.TryGetProperty("data", out var dataElement))
|
||||
// {
|
||||
// Console.WriteLine($"data 요소 타입: {dataElement.ValueKind}");
|
||||
|
||||
// // 전체 data를 JSON 문자열로 변환
|
||||
// var userDataJson = dataElement.ToString();
|
||||
|
||||
// // 전체 데이터 암호화
|
||||
// var encryptedUserData = await SecureService.EncryptAsync(userDataJson);
|
||||
// await StorageService.SetItemAsync("USER_DATA", encryptedUserData);
|
||||
|
||||
// // 기존 name 처리 로직
|
||||
// if (dataElement.TryGetProperty("name", out var nameElement))
|
||||
// {
|
||||
// UserName = nameElement.GetString() ?? "이름 없음";
|
||||
// isLogin = true;
|
||||
// Console.WriteLine($"NM: {UserName}");
|
||||
// var encryptedUserName = await SecureService.EncryptAsync(UserName);
|
||||
// Console.WriteLine($"NM: {encryptedUserName}");
|
||||
// await StorageService.SetItemAsync("USER", encryptedUserName);
|
||||
// await StorageService.SetItemAsync("Web_AM_Connect_Key", headerValue);
|
||||
// Console.WriteLine($"로그인된 사용자: {UserName}");
|
||||
// return;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// else {
|
||||
// if (isLogin) {
|
||||
// isLogin = false;
|
||||
// await StorageService.SetItemAsync("IsLogin","false");
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// Console.WriteLine("로그인되지 않은 상태");
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine($"응답 처리 중 오류 발생: {ex.Message}");
|
||||
// Console.WriteLine($"응답 처리 스택 트레이스: {ex.StackTrace}");
|
||||
// }
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine($"세션 확인 중 오류 발생: {ex.Message}");
|
||||
// Console.WriteLine($"스택 트레이스: {ex.StackTrace}");
|
||||
// }
|
||||
}
|
||||
|
||||
public void OnClickMenuDown()
|
||||
|
@ -145,19 +157,13 @@ public partial class TopProjectNav : ComponentBase
|
|||
if (isOpen) isOpen = !isOpen;
|
||||
NavigationManager.NavigateTo("/auth");
|
||||
}
|
||||
|
||||
public async Task OnClickLogout()
|
||||
{
|
||||
// var isRemoved = await StorageService.RemoveItemAsync("USER");
|
||||
if (await StorageService.RemoveItemAsync("IsLogin")) {
|
||||
isLogin = false;
|
||||
if (await StorageService.RemoveItemAsync("USER")) {
|
||||
UserName = null;
|
||||
Console.WriteLine("LOGOUT");
|
||||
}
|
||||
}
|
||||
else
|
||||
if (await UserService.ClearUserData())
|
||||
{
|
||||
Console.WriteLine("로그아웃 처리 중 오류가 발생했습니다.");
|
||||
isLogin = false;
|
||||
UserName = null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,6 +10,6 @@
|
|||
@using Front.Program.Layout
|
||||
|
||||
@using Front.Program.Views.Project
|
||||
@* @using Front.Program.Views.Academy *@
|
||||
@using Front.Program.Views.Academy
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user