Login, Register; improvements, fixes, etc...

This commit is contained in:
jozsef.b@aycode.com 2024-04-22 17:30:14 +02:00
parent 1328c467be
commit 65173cea1c
24 changed files with 247 additions and 76 deletions

View File

@ -0,0 +1,14 @@
using AyCode.Core.Consts;
namespace TIAM.Core.Consts;
public class TiamConst : AcConst
{
public static string ProjectIdString = "684f34d1-163a-4077-918f-a9d9df5ce789";
static TiamConst()
{
ProjectId = Guid.Parse(ProjectIdString);
ProjectSalt = GenerateProjectSalt(ProjectId.ToString("N"));
}
}

View File

@ -14,6 +14,7 @@ using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
using TIAM.Entities.Profiles; using TIAM.Entities.Profiles;
using AyCode.Core.Extensions;
namespace TIAM.Database.Test namespace TIAM.Database.Test
{ {
@ -604,7 +605,7 @@ namespace TIAM.Database.Test
user.Profile = profile; user.Profile = profile;
user.Profile.Address = address; user.Profile.Address = address;
Assert.IsTrue(await Dal.AddUser(user)); Assert.IsTrue(await Dal.AddUserAsync(user));
user = Dal.GetUserById(userId); user = Dal.GetUserById(userId);
Assert.IsNotNull(user); Assert.IsNotNull(user);

View File

@ -10,14 +10,32 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" /> <None Remove="appsettings.Development.json" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.3" /> <None Remove="appsettings.json" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.3" /> </ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" />
<ItemGroup>
<Content Include="appsettings.Development.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
<Content Include="appsettings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<ExcludeFromSingleFile>true</ExcludeFromSingleFile>
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
</Content>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Moq" Version="4.20.70" /> <PackageReference Include="Moq" Version="4.20.70" />
<PackageReference Include="MSTest.TestAdapter" Version="3.2.2" /> <PackageReference Include="MSTest.TestAdapter" Version="3.3.1" />
<PackageReference Include="MSTest.TestFramework" Version="3.2.2" /> <PackageReference Include="MSTest.TestFramework" Version="3.3.1" />
<PackageReference Include="coverlet.collector" Version="6.0.2"> <PackageReference Include="coverlet.collector" Version="6.0.2">
<PrivateAssets>all</PrivateAssets> <PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
@ -29,6 +47,7 @@
<ProjectReference Include="..\TIAM.Database\TIAM.Database.csproj" /> <ProjectReference Include="..\TIAM.Database\TIAM.Database.csproj" />
<ProjectReference Include="..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" /> <ProjectReference Include="..\TIAM.Entities.Server\TIAM.Entities.Server.csproj" />
<ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" /> <ProjectReference Include="..\TIAM.Entities\TIAM.Entities.csproj" />
<ProjectReference Include="..\TIAMWebApp\Server\TIAMWebApp.Server.csproj" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -14,19 +14,33 @@ using TIAM.Entities.Profiles;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using AyCode.Interfaces.Users.Dtos; using AyCode.Interfaces.Users.Dtos;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using TIAM.Core.Consts;
using TIAM.Entities.ServiceProviders; using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Addresses; using TIAM.Entities.Addresses;
using TIAMWebApp.Server.Services.Logins;
//using static Microsoft.ApplicationInsights.MetricDimensionNames.TelemetryContext;
namespace TIAM.Database.Test namespace TIAM.Database.Test
{ {
[TestClass] [TestClass]
public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider, Address> public class UserDalTests : AcUserDalTestBase<UserDal, UserDbContext, User, Profile, UserToken, TiamServiceProvider, UserToServiceProvider, Address>
{ {
private Mock<UserDbContext> _mockContext; private WebAssemblyHostConfiguration _configuration = new WebAssemblyHostConfiguration();
//private Mock<UserDbContext> _mockContext;
[TestInitialize] [TestInitialize]
public void TestInitialize() public void TestInitialize()
{ {
_configuration = new WebAssemblyHostConfiguration();
_configuration.Build();
_configuration.Reload();
//_configuration["JWT:Key"] = "Cee4400-rDMFkVvHPufyLDSzbfu2grgRhpepos299IhTLOXsljkcpt3yUR4RRjPQ";
//_configuration["JWT:Audience"] = "http://localhost:5000";
//_configuration["JWT:Issuer"] = "http://localhost:5000";
//var options = new DbContextOptionsBuilder<UserDbContext>() //var options = new DbContextOptionsBuilder<UserDbContext>()
// .UseInMemoryDatabase(databaseName: "UserDatabase") // .UseInMemoryDatabase(databaseName: "UserDatabase")
// .Options; // .Options;
@ -39,6 +53,29 @@ namespace TIAM.Database.Test
//_userDal = new UserDal(_mockContext.Object); //_userDal = new UserDal(_mockContext.Object);
} }
//[TestMethod]
public async Task RegisterUser_ReturnsUser_WhenUserExist()
{
//var a = TiamConst.ProjectIdString;
var userId = Guid.Parse("1ded6045-1278-4b92-a10a-3eb9426e41a3");
//await Dal.RemoveUserAsync(userId); //kitöröljük a szemetet, ha korábbról bentmaradt - J.
var loginService = new LoginService(Dal, new WebAssemblyHostConfiguration());
var user = await loginService.RegistrationAsync(userId, "asdfsdf@ggggg.hu", "alad'r", null);
Assert.IsNotNull(user);
}
[TestMethod]
public void LoginUser_ReturnsUser_WhenUserExist()
{
//var a = TiamConst.ProjectIdString;
var loginService = new LoginService(Dal, _configuration);
var user = loginService.Login("asdfsdf@ggggg.hu", "alad'r", out _);
Assert.IsNotNull(user);
}
[TestMethod] [TestMethod]
[DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")] [DataRow("540271F6-C604-4C16-8160-D5A7CAFEDF00")]
public void GetUserById_ReturnsUser_WhenUserAndRelationsExists(string userIdString) public void GetUserById_ReturnsUser_WhenUserAndRelationsExists(string userIdString)

View File

@ -0,0 +1,17 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"JWT": {
"Key": "Cee4400-rDMFkVvHPufyLDSzbfu2grgRhpepos299IhTLOXsljkcpt3yUR4RRjPQ",
"Issuer": "https://localhost:7116",
"Audience": "http://localhost:7116"
},
"SendGrid": {
//"Key": "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"
"Key": "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"
}
}

View File

@ -0,0 +1,22 @@
{
"ConnectionStrings": {
"DeveloperDbConnection": "Data Source=185.51.190.197;Initial Catalog=TIAM_DEV;Trusted_Connection=False;Connect Timeout=200;User ID=Anata_Development_Team;Password=v6f_?xNfg9N1;MultipleActiveResultSets=true"
},
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"JWT": {
"Key": "Cee4400-rDMFkVvHPufyLDSzbfu2grgRhpepos299IhTLOXsljkcpt3yUR4RRjPQ",
"Issuer": "http://localhost:5000",
"Audience": "http://localhost:5000"
},
"SendGrid": {
//"Key": "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"
"Key": "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"
}
}

View File

@ -101,19 +101,21 @@ namespace TIAM.Database.DataLayers.Admins
public string? GetUserJsonById(Guid userId) => Session(ctx => ctx.GetUserById(userId)?.ToJson()); public string? GetUserJsonById(Guid userId) => Session(ctx => ctx.GetUserById(userId)?.ToJson());
public string GetUsersJson() => Session(ctx => ctx.Users.ToJson()); public string GetUsersJson() => Session(ctx => ctx.Users.ToJson());
public Task<bool> AddUser(User user) => TransactionAsync(ctx => ctx.AddUser(user)); public Task<bool> AddUserAsync(User user) => TransactionAsync(ctx => ctx.AddUser(user));
public Task<bool> AddUser(User user, string profileName, Address address, string? firstName = null, string? lastName = null) public Task<bool> AddUserAsync(User user, string profileName, Address address, string? firstName = null, string? lastName = null)
{ {
return TransactionAsync(ctx => return TransactionAsync(ctx =>
{ {
var profile = Activator.CreateInstance<Profile>(); var profile = new Profile
{
profile.Id = Guid.NewGuid(); Id = Guid.NewGuid(),
profile.Name = profileName; Name = profileName,
profile.FirstName = firstName; FirstName = firstName,
profile.LastName = lastName; LastName = lastName,
profile.Address = address; Address = address,
AddressId = address.Id
};
user.Profile= profile; user.Profile= profile;
@ -129,10 +131,10 @@ namespace TIAM.Database.DataLayers.Admins
public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson()); public string GetProductsJson(bool includeUsers = true) => Session(ctx => ctx.ProductsWithUserRelations(includeUsers).ToJson());
public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToList()); public List<Product> GetProductsByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToList());
public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToJson()); public string GetProductsJsonByServiceProviderId(Guid serviceProviderId, bool includeUsers = true) => Session(ctx => ctx.GetProductsByServiceProviderId(serviceProviderId, includeUsers).ToJson());
public Task<bool> AddProduct(Product product) => TransactionAsync(ctx => ctx.AddProduct(product)); public Task<bool> AddProductAsync(Product product) => TransactionAsync(ctx => ctx.AddProduct(product));
public Task<bool> UpdateProduct(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(product)); public Task<bool> UpdateProductAsync(Product product) => TransactionAsync(ctx => ctx.UpdateProduct(product));
public Task<bool> RemoveProduct(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product)); public Task<bool> RemoveProductAsync(Product product) => TransactionAsync(ctx => ctx.RemoveProduct(product));
public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude)); public UserProductMapping? GetUserProductMappingById(Guid userProductMappingId, bool autoInclude = true) => Session(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude)); public Task<UserProductMapping?> GetUserProductMappingByIdAsync(Guid userProductMappingId, bool autoInclude = true) => SessionAsync(ctx => ctx.GetUserProductMappingById(userProductMappingId, autoInclude));
@ -223,8 +225,8 @@ namespace TIAM.Database.DataLayers.Admins
{ {
Context.CreateProduct(product); Context.CreateProduct(product);
Console.WriteLine($"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}"); Console.WriteLine($"Saving product to db {product.Id}, {product.Name}, {product.ServiceProviderId}");
var _result = Context.SaveChangesAsync(); var result = Context.SaveChangesAsync();
return _result.Result > 0; return result.Result > 0;
} }
public Task<List<TiamServiceProvider>> GetServiceProvidersAsync() public Task<List<TiamServiceProvider>> GetServiceProvidersAsync()

View File

@ -7,9 +7,9 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Proxies" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup> </ItemGroup>

View File

@ -32,7 +32,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="8.0.4" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -52,8 +52,8 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" /> <PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="8.0.0" />
<PackageReference Include="SkiaSharp" Version="2.88.7" /> <PackageReference Include="SkiaSharp" Version="2.88.8" />
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" /> <PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.8" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -83,15 +83,15 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Update="Microsoft.AspNetCore.Components.WebView.Maui" Version="8.0.14" /> <PackageReference Update="Microsoft.AspNetCore.Components.WebView.Maui" Version="8.0.20" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Update="Microsoft.Maui.Controls" Version="8.0.14" /> <PackageReference Update="Microsoft.Maui.Controls" Version="8.0.20" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.14" /> <PackageReference Update="Microsoft.Maui.Controls.Compatibility" Version="8.0.20" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -17,6 +17,7 @@ using DevExpress.XtraPrinting;
using TIAMSharedUI.Shared; using TIAMSharedUI.Shared;
using DevExpress.Pdf.Native.BouncyCastle.Asn1.Cms; using DevExpress.Pdf.Native.BouncyCastle.Asn1.Cms;
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using AyCode.Core.Consts;
namespace TIAMSharedUI.Pages.Components namespace TIAMSharedUI.Pages.Components
@ -213,7 +214,7 @@ namespace TIAMSharedUI.Pages.Components
editor.OpenComponent<DxMaskedInput<string>>(j++); editor.OpenComponent<DxMaskedInput<string>>(j++);
editor.AddAttribute(j++, "Value", property.GetValue(Data)); editor.AddAttribute(j++, "Value", property.GetValue(Data));
editor.AddAttribute(j++, "Mask", TIAMRegularExpressions.PhoneNumberMask); editor.AddAttribute(j++, "Mask", AcRegExpression.PhoneNumberMask);
editor.AddAttribute(j++, "MaskMode", MaskMode.RegEx); editor.AddAttribute(j++, "MaskMode", MaskMode.RegEx);
editor.AddAttribute(j++, "BindValueMode", BindValueMode.OnInput); editor.AddAttribute(j++, "BindValueMode", BindValueMode.OnInput);
editor.AddAttribute(j++, "NullText", "+11234567890"); editor.AddAttribute(j++, "NullText", "+11234567890");
@ -238,7 +239,7 @@ namespace TIAMSharedUI.Pages.Components
{ {
editor.OpenComponent<DxMaskedInput<string>>(j++); editor.OpenComponent<DxMaskedInput<string>>(j++);
editor.AddAttribute(j++, "Value", property.GetValue(Data)); editor.AddAttribute(j++, "Value", property.GetValue(Data));
editor.AddAttribute(j++, "Mask", TIAMRegularExpressions.EmailMask); editor.AddAttribute(j++, "Mask", AcRegExpression.EmailMask);
editor.AddAttribute(j++, "MaskMode", MaskMode.RegEx); editor.AddAttribute(j++, "MaskMode", MaskMode.RegEx);
editor.AddAttribute(j++, "BindValueMode", BindValueMode.OnInput); editor.AddAttribute(j++, "BindValueMode", BindValueMode.OnInput);

View File

@ -1,5 +1,6 @@
@using TIAMWebApp.Shared.Application.Models.PageModels; @using TIAMWebApp.Shared.Application.Models.PageModels;
@using TIAMWebApp.Shared.Application.Utility; @using TIAMWebApp.Shared.Application.Utility;
@using AyCode.Core.Consts
<EditForm Model="@regModel" OnValidSubmit="GoToNextStep"> <EditForm Model="@regModel" OnValidSubmit="GoToNextStep">
<DataAnnotationsValidator /> <DataAnnotationsValidator />
@ -44,7 +45,7 @@
public EventCallback<RegistrationModel> RegModelChanged { get; set; } public EventCallback<RegistrationModel> RegModelChanged { get; set; }
//string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}"; //string EmailMask { get; set; } = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}";
string EmailMask { get; set; } = TIAMRegularExpressions.EmailMask; string EmailMask { get; set; } = AcRegExpression.EmailMask;
MaskAutoCompleteMode AutoCompleteMode { get; set; } = MaskAutoCompleteMode.Strong; MaskAutoCompleteMode AutoCompleteMode { get; set; } = MaskAutoCompleteMode.Strong;
char Placeholder { get; set; } = '_'; char Placeholder { get; set; } = '_';
bool PlaceholderVisible { get; set; } = false; bool PlaceholderVisible { get; set; } = false;

View File

@ -1,5 +1,6 @@
@using TIAMWebApp.Shared.Application.Models.PageModels; @using TIAMWebApp.Shared.Application.Models.PageModels;
@using TIAMWebApp.Shared.Application.Utility; @using TIAMWebApp.Shared.Application.Utility;
@using AyCode.Core.Consts
<h3>Step 2: Phone Number</h3> <h3>Step 2: Phone Number</h3>
<EditForm Model="@regModel" OnValidSubmit="GoToNextStep"> <EditForm Model="@regModel" OnValidSubmit="GoToNextStep">
@ -48,7 +49,7 @@
public EventCallback<RegistrationModel> RegModelChanged { get; set; } public EventCallback<RegistrationModel> RegModelChanged { get; set; }
//public string PhoneNumberMask { get; set; } = "\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*(\d{1,2})"; //public string PhoneNumberMask { get; set; } = "\+(9[976]\d|8[987530]\d|6[987]\d|5[90]\d|42\d|3[875]\d|2[98654321]\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*\d\W*(\d{1,2})";
public string PhoneNumberMask { get; set; } = TIAMRegularExpressions.PhoneNumberMask; public string PhoneNumberMask { get; set; } = AcRegExpression.PhoneNumberMask;
char Placeholder = '_'; char Placeholder = '_';

View File

@ -1,4 +1,5 @@
@using AyCode.Utils.Extensions @using AyCode.Core.Extensions
@using AyCode.Utils.Extensions
@if (Users == null) @if (Users == null)
{ {
<p> <p>

View File

@ -15,8 +15,8 @@
<PackageReference Include="Blazor.AnimateOnScroll" Version="1.1.0" /> <PackageReference Include="Blazor.AnimateOnScroll" Version="1.1.0" />
<PackageReference Include="BlazorAnimation" Version="2.2.0" /> <PackageReference Include="BlazorAnimation" Version="2.2.0" />
<PackageReference Include="DevExpress.Blazor" Version="23.2.3" /> <PackageReference Include="DevExpress.Blazor" Version="23.2.3" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.4" />
<PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.3" /> <PackageReference Include="Microsoft.Extensions.Localization" Version="8.0.4" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
@ -32,6 +32,9 @@
<Reference Include="AyCode.Core"> <Reference Include="AyCode.Core">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Core.dll</HintPath> <HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Core.dll</HintPath>
</Reference> </Reference>
<Reference Include="AyCode.Core.Server">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Core.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Entities"> <Reference Include="AyCode.Entities">
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Entities.dll</HintPath> <HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Entities.dll</HintPath>
</Reference> </Reference>

View File

@ -11,10 +11,10 @@
<ItemGroup> <ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.5.0" /> <PackageReference Include="Blazored.LocalStorage" Version="4.5.0" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.3" PrivateAssets="all" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="8.0.4" PrivateAssets="all" />
<PackageReference Include="SkiaSharp" Version="2.88.7" /> <PackageReference Include="SkiaSharp" Version="2.88.8" />
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" /> <PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.8" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -156,7 +156,7 @@ namespace TIAMWebApp.Server.Controllers
new LocationEx(destination1), new LocationEx(destination1),
new LocationEx(destination2) new LocationEx(destination2)
}, },
TravelMode = TravelMode.Driving, TravelMode = TravelMode.DRIVING,
}; };
response = await GoogleApi.GoogleMaps.DistanceMatrix.QueryAsync(request); response = await GoogleApi.GoogleMaps.DistanceMatrix.QueryAsync(request);

View File

@ -176,7 +176,7 @@ namespace TIAMWebApp.Server.Controllers
} }
else else
{ {
var result = _adminDal.AddProduct(product); var result = _adminDal.AddProductAsync(product);
return Ok(result); return Ok(result);
} }
} }

View File

@ -39,7 +39,7 @@ namespace TIAMWebApp.Server.Controllers
private AdminDal _adminDal; private AdminDal _adminDal;
private readonly IConfiguration _configuration; private readonly IConfiguration _configuration;
private readonly IWebHostEnvironment _webHostEnvironment; private readonly IWebHostEnvironment _webHostEnvironment;
readonly PasswordHasher _hasher = new(); //readonly PasswordHasher _hasher = new();
/*private UserModel[] users = new UserModel[] /*private UserModel[] users = new UserModel[]
@ -366,7 +366,7 @@ namespace TIAMWebApp.Server.Controllers
userToCreate.Profile.Address.AddressText = null; userToCreate.Profile.Address.AddressText = null;
userToCreate.Profile.Address.Latitude = Math.Round(90 + rnd.NextDouble(), 8); userToCreate.Profile.Address.Latitude = Math.Round(90 + rnd.NextDouble(), 8);
userToCreate.Profile.Address.Longitude = Math.Round(180 + rnd.NextDouble(), 8); userToCreate.Profile.Address.Longitude = Math.Round(180 + rnd.NextDouble(), 8);
result = await _adminDal.AddUser(userToCreate); result = await _adminDal.AddUserAsync(userToCreate);
guestUser = await _userDal.GetUserModelDtoDetailByIdAsync(userId); guestUser = await _userDal.GetUserModelDtoDetailByIdAsync(userId);
} }
} }
@ -415,13 +415,13 @@ namespace TIAMWebApp.Server.Controllers
private bool VerifyPassword(string password, string hashedPassword) private bool VerifyPassword(string password, string hashedPassword)
{ {
var isPasswordValid = _hasher.VerifyPassword(password, hashedPassword); var isPasswordValid = PasswordHasher.VerifyPassword(password, hashedPassword);
return isPasswordValid; return isPasswordValid;
} }
private string HashPassword(string password) private string HashPassword(string password)
{ {
var hashedPassword = _hasher.HashPassword(password); var hashedPassword = PasswordHasher.HashPassword(password);
return hashedPassword; return hashedPassword;
} }
} }

View File

@ -0,0 +1,17 @@
using AyCode.Interfaces.Server.Logins;
using AyCode.Models.Logins;
using AyCode.Models.Server.Logins;
using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
namespace TIAMWebApp.Server.Services.Logins;
public interface ILoginModel : IAcLoggedInModelBase<User, Profile, TiamServiceProvider, UserToServiceProvider, Address>
{}
public interface ILoginService : IAcLoginServiceServer<User, UserToken, Profile, TiamServiceProvider, UserToServiceProvider, Address>
{
}

View File

@ -0,0 +1,46 @@
using System.Reflection.Metadata.Ecma335;
using System.Security;
using AyCode.Core.Consts;
using AyCode.Interfaces.Server.Logins;
using AyCode.Models.Server.Logins;
using AyCode.Services.Server.Logins;
using AyCode.Utils.Extensions;
using AyCode.Utils.Helpers;
using TIAM.Database.DataLayers.Admins;
using TIAM.Database.DataLayers.Users;
using TIAM.Database.DbContexts.Admins;
using TIAM.Database.DbContexts.Users;
using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles;
using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
namespace TIAMWebApp.Server.Services.Logins;
public class LoggedInModel : AcLoggedInModelServer<User, Profile, TiamServiceProvider, UserToServiceProvider, Address>, ILoginModel
{}
public class LoginService(UserDal userDal, IConfiguration configuration) : AcLoginServiceServer<LoggedInModel, UserDal, UserDbContext, User, UserToken, Profile, TiamServiceProvider, UserToServiceProvider, Address>(userDal, configuration), ILoginService
{
public override User? Login(string email, string password, out string accessToken)
{
return base.Login(email, password, out accessToken);
}
public override bool Logout()
{
return base.Logout();
}
public override Task<User?> RegistrationAsync(string email, string password, string? phoneNumber = null)
{
return base.RegistrationAsync(email, password, phoneNumber);
}
public override string GenerateDynamicSalt(Guid userId)
{
return base.GenerateDynamicSalt(userId);
}
}

View File

@ -10,15 +10,15 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="GoogleApi" Version="5.3.1" /> <PackageReference Include="GoogleApi" Version="5.4.0" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Server" Version="8.0.4" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.3" /> <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="8.0.4" />
<PackageReference Include="Microsoft.OpenApi" Version="1.6.14" /> <PackageReference Include="Microsoft.OpenApi" Version="1.6.14" />
<PackageReference Include="QRCoderNetCore" Version="1.0.0" /> <PackageReference Include="QRCoderNetCore" Version="1.0.0" />
<PackageReference Include="SendGrid" Version="9.29.2" /> <PackageReference Include="SendGrid" Version="9.29.3" />
<PackageReference Include="SkiaSharp" Version="2.88.7" /> <PackageReference Include="SkiaSharp" Version="2.88.8" />
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" /> <PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.8" />
<PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore.Swagger" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="6.5.0" />
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" /> <PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="6.5.0" />
@ -61,6 +61,12 @@
<Reference Include="AyCode.Models.Server"> <Reference Include="AyCode.Models.Server">
<HintPath>..\..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.Server.dll</HintPath> <HintPath>..\..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.Server.dll</HintPath>
</Reference> </Reference>
<Reference Include="AyCode.Services">
<HintPath>..\..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Services.dll</HintPath>
</Reference>
<Reference Include="AyCode.Services.Server">
<HintPath>..\..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Services.Server.dll</HintPath>
</Reference>
<Reference Include="AyCode.Utils"> <Reference Include="AyCode.Utils">
<HintPath>..\..\..\AyCode.Core\AyCode.Utils\bin\Debug\net8.0\AyCode.Utils.dll</HintPath> <HintPath>..\..\..\AyCode.Core\AyCode.Utils\bin\Debug\net8.0\AyCode.Utils.dll</HintPath>
</Reference> </Reference>

View File

@ -17,11 +17,11 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.3" /> <PackageReference Include="Microsoft.AspNetCore.Cryptography.KeyDerivation" Version="8.0.4" />
<PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" /> <PackageReference Include="Microsoft.AspNetCore.Http.Features" Version="5.0.17" />
<PackageReference Include="Microsoft.JSInterop" Version="8.0.3" /> <PackageReference Include="Microsoft.JSInterop" Version="8.0.4" />
<PackageReference Include="SkiaSharp" Version="2.88.7" /> <PackageReference Include="SkiaSharp" Version="2.88.8" />
<PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.7" /> <PackageReference Include="SkiaSharp.Views.Desktop.Common" Version="2.88.8" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>

View File

@ -1,17 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TIAMWebApp.Shared.Application.Utility
{
public static class TIAMRegularExpressions
{
public const string EmailMask = @"(\w|[.-])+@(\w|-)+\.(\w|-){2,4}";
//public const string EmailMask = @"((\w|[.-])+@(\w|-)+\.(\w|-){2,4})?";
public const string PhoneNumberMask = "\\+(9[976]\\d|8[987530]\\d|6[987]\\d|5[90]\\d|42\\d|3[875]\\d|2[98654321]\\d|9[8543210]|8[6421]|6[6543210]|5[87654321]|4[987654310]|3[9643210]|2[70]|7|1)\\W*\\d\\W*\\d\\W*\\d\\W*\\d\\W*\\d\\W*\\d\\W*\\d\\W*\\d\\W*(\\d{1,2})";
}
}