Hi,
Trying to allow users to login from a sidepanel in my layout, but can't seem to get the code for the method right.
probably missing something obvious, but cant see it in the source (using the nuget in my project so trawling the github (which is slow)) and can't see anything that looks recent with a few like this from the last c10-12 years.
[color=var(--bs-body-color)][font=system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", "Noto Sans", "Liberation Sans", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji"]without rambling too much.[/font][/color]
here's what i have
private async Task LoginClick()
{
try
{
var baseUri = NavigationManager.BaseUri.EndsWith("/")
? NavigationManager.BaseUri
: $"{NavigationManager.BaseUri}/";
// Use the LoginBox controller endpoint instead of Account/Login
var loginUrl = $"{baseUri}LoginBox/SignIn";
// Create form data matching YAF's expected format
var formData = new MultipartFormDataContent
{
{ new StringContent(username), "UserName" },
{ new StringContent(password), "Password" },
{ new StringContent(rememberMe.ToString()), "RememberMe" }
};
Console.WriteLine($"Attempting login at: {loginUrl}");
var response = await HttpClient.PostAsync(loginUrl, formData);
if (response.IsSuccessStatusCode)
{
NavigationManager.NavigateTo(NavigationManager.Uri, true);
}
else
{
var error = await response.Content.ReadAsStringAsync();
Console.WriteLine($"Login failed with status {response.StatusCode}: {error}");
StateHasChanged();
}
}
catch (Exception ex)
{
Console.WriteLine($"Login error: {ex.Message}");
}
}
probably trying to mush together a whole lot of different solutions, if i can get pointed to the right code that would also help.
Thanks a million looking forwards to showing you all what i've got so far.