Compare commits

...

2 Commits

  1. 5
      .gitignore
  2. 2
      Client/Elements/Headbar.razor
  3. 46
      Server/Services/AuthenticationService.cs

5
.gitignore

@ -10,6 +10,7 @@
*.userosscache
*.sln.docstates
# User-specific files (MonoDevelop/Xamarin Studio)
*.userprefs
@ -32,7 +33,7 @@ bld/
[Oo]ut/
[Ll]og/
[Ll]ogs/
.config
# Visual Studio 2015/2017 cache/options directory
.vs/
# Uncomment if you have tasks that create the project's static files in wwwroot
@ -361,3 +362,5 @@ MigrationBackup/
# Fody - auto-generated XML schema
FodyWeavers.xsd
/Server/.config/dotnet-tools.json
/Server/.config/dotnet-tools.json

2
Client/Elements/Headbar.razor

@ -28,7 +28,7 @@
<div id="Profile" @onclick="@ToggleDropdown">
<i class="bx bxs-user fs-4 lh-0"></i>
<ul class=@m_dropDownClass style="width: 150px;">
<ul class=@m_dropDownClass style="width: 150px;right: 5px;">
<li><a href="#">Profile</a></li>
<li><a href="#">Account</a></li>
<li><a href="#">Settings</a></li>

46
Server/Services/AuthenticationService.cs

@ -1,4 +1,5 @@
using Biskilog_Accounting.Shared.ClientContractModels;
using BCrypt.Net;
using Biskilog_Accounting.Shared.ClientContractModels;
using Biskilog_Accounting.Shared.Enums;
using Biskilog_Accounting.Shared.Interfaces;
using Microsoft.EntityFrameworkCore;
@ -118,28 +119,33 @@ namespace Biskilog_Accounting.Server.Services
return m_context.Siteaccesspermissions.Where(t => t.ClientId == a_clientId && t.UserId == a_userId).ToList();
}
private async Task<Userauth> GetUserAsync(string username, string password)
private async Task<Userauth?> GetUserAsync(string username, string password)
{
//Todo have complete implementation after means of creating user is done
//try
//{
// string pa = await m_context.Userauths.Where(u => u.Username == username).Select(u => u.Password).FirstAsync();
// bool verified = BCrypt.Net.BCrypt.Verify(password, pa);
// if (verified)
// {
try
{
string? pa = await m_context.Userauths.Where(u => u.Username == username || u.Email == username).Select(u => u.Passsword).FirstOrDefaultAsync();
//TODO have a complete implementation
return await m_context.Userauths.FirstAsync(u => u.Username == username && u.Passsword == password);
// }
// else
// {
// return null;
// }
//}catch(Exception ex)
//{
// //possible is user not found
// return null;
//}
if (String.IsNullOrEmpty(pa))
{
return null;
}
bool verified = BCrypt.Net.BCrypt.Verify(password, pa);
if (verified)
{
return await m_context.Userauths.FirstAsync(u => u.Username == username || u.Email == username);
}
else
{
return null;
}
}
catch (Exception ex)
{
//possible is user not found
return null;
}
}
}
}

Loading…
Cancel
Save