AcaMate_Web/Program/Views/Project/Auth.razor.cs

29 lines
1021 B
C#

using Front.Program.Services;
using Microsoft.AspNetCore.Components;
using Microsoft.JSInterop;
namespace Front.Program.Views.Project;
public partial class Auth : ComponentBase
{
[Inject] NavigationManager NavigationManager { get; set; } = default!;
[Inject] IJSRuntime JS { get; set; } = default!;
[Inject] CookieService Cookie {get; set;} = default!;
public async Task KakaoLogin()
{
var headerKey = "Web_AM_Connect_Key";
// var headerValue = await JS.InvokeAsync<string>("eval", "document.cookie.match(/Web_AM_Connect_Key=([^;]+)/)?.[1] || ''");
// NavigationManager.NavigateTo("/api/v1/in/user/kakao/auth", true);
Cookie.GetCookieAsync(headerKey).ContinueWith(async task =>
{
var cookie = task.Result;
if (!string.IsNullOrEmpty(cookie))
{
await JS.InvokeVoidAsync("postWithHeader", "/api/v1/in/user/kakao/auth", "GET", headerKey, cookie);
}
});
}
}