-
- @if (tried)
- {
- @if (verified)
- {
-
Verifed!
- }
- else
- {
-
False login
- }
- }
- else
- {
-
Plz login
- }
-
+
@code {
private string Email { get; set; }
private string Password { get; set; }
- private bool verified = false;
- private bool tried = false;
+ private bool verified;
- private async Task SubmitForm()
+ private async Task login()
{
- tried = true;
- AccountData target = (await AccountsRepository.getAccountsByMailAsync(Email))[0];
- if (target == null)
+ Console.WriteLine("loggin you in...");
+ var user = await UsersRepository.getUserByEmailAsync(Email);
+ if (user == null)
{
+ await js.InvokeVoidAsync("alert", "User does not exist");
verified = false;
return;
}
- verified = BCrypt.Net.BCrypt.Verify(Password, target.Password);
+ verified = BCrypt.Net.BCrypt.Verify(Password, user.Password);
if (verified)
{
verified = true;
+ var customAuthStateProvider = (CustomAuthenticationStateProvider)authStateProvider;
+ await customAuthStateProvider.UpdateAuthenticationStateAsync(user);
+ navManager.NavigateTo("/", true);
return;
}
- verified = false;
+ await js.InvokeVoidAsync("alert", $"Wrong creds:\n{BCrypt.Net.BCrypt.HashPassword(Password)}");
}
+
+ /*
+ *
+ UserData target = (await UsersRepository.getUserByEmailAsync(Email));
+
+ */
}
\ No newline at end of file
diff --git a/ImageBoardServerApp/Program.cs b/ImageBoardServerApp/Program.cs
index 9e80ae6..4f3c1fb 100644
--- a/ImageBoardServerApp/Program.cs
+++ b/ImageBoardServerApp/Program.cs
@@ -1,14 +1,15 @@
-using ImageBoardServerApp.Data;
-using Microsoft.AspNetCore.Components;
-using Microsoft.AspNetCore.Components.Web;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Design;
+using ImageBoardServerApp.Auth;
+using Microsoft.AspNetCore.Components.Authorization;
+using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
+builder.Services.AddAuthenticationCore();
builder.Services.AddRazorPages();
builder.Services.AddServerSideBlazor();
+builder.Services.AddScoped