|
@ -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.Enums; |
|
|
using Biskilog_Accounting.Shared.Interfaces; |
|
|
using Biskilog_Accounting.Shared.Interfaces; |
|
|
using Microsoft.EntityFrameworkCore; |
|
|
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(); |
|
|
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
|
|
|
//Todo have complete implementation after means of creating user is done
|
|
|
//try
|
|
|
try |
|
|
//{
|
|
|
{ |
|
|
// string pa = await m_context.Userauths.Where(u => u.Username == username).Select(u => u.Password).FirstAsync();
|
|
|
string? pa = await m_context.Userauths.Where(u => u.Username == username || u.Email == username).Select(u => u.Passsword).FirstOrDefaultAsync(); |
|
|
// bool verified = BCrypt.Net.BCrypt.Verify(password, pa);
|
|
|
|
|
|
// if (verified)
|
|
|
|
|
|
// {
|
|
|
|
|
|
|
|
|
|
|
|
//TODO have a complete implementation
|
|
|
if (String.IsNullOrEmpty(pa)) |
|
|
return await m_context.Userauths.FirstAsync(u => u.Username == username && u.Passsword == password); |
|
|
{ |
|
|
// }
|
|
|
return null; |
|
|
// else
|
|
|
} |
|
|
// {
|
|
|
bool verified = BCrypt.Net.BCrypt.Verify(password, pa); |
|
|
// return null;
|
|
|
if (verified) |
|
|
// }
|
|
|
{ |
|
|
//}catch(Exception ex)
|
|
|
|
|
|
//{
|
|
|
return await m_context.Userauths.FirstAsync(u => u.Username == username || u.Email == username); |
|
|
// //possible is user not found
|
|
|
} |
|
|
// return null;
|
|
|
else |
|
|
//}
|
|
|
{ |
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
catch (Exception ex) |
|
|
|
|
|
{ |
|
|
|
|
|
//possible is user not found
|
|
|
|
|
|
return null; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|