mirror of
https://github.com/aaronpo97/the-biergarten-app.git
synced 2026-10-15 10:04:44 +00:00
Format
This commit is contained in:
13
web/backend/.config/dotnet-tools.json
Normal file
13
web/backend/.config/dotnet-tools.json
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"version": 1,
|
||||||
|
"isRoot": true,
|
||||||
|
"tools": {
|
||||||
|
"csharpier": {
|
||||||
|
"version": "1.3.0",
|
||||||
|
"commands": [
|
||||||
|
"csharpier"
|
||||||
|
],
|
||||||
|
"rollForward": false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,37 +1,35 @@
|
|||||||
<Solution>
|
<Solution>
|
||||||
<Folder Name="/API/">
|
<Folder Name="/API/">
|
||||||
<Project Path="API/API.Core/API.Core.csproj"/>
|
<Project Path="API/API.Core/API.Core.csproj" />
|
||||||
<Project Path="API/API.Specs/API.Specs.csproj"/>
|
<Project Path="API/API.Specs/API.Specs.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder Name="/Database/">
|
<Folder Name="/Database/">
|
||||||
<Project Path="Database/Database.Migrations/Database.Migrations.csproj"/>
|
<Project Path="Database/Database.Migrations/Database.Migrations.csproj" />
|
||||||
<Project Path="Database/Database.Seed/Database.Seed.csproj"/>
|
<Project Path="Database/Database.Seed/Database.Seed.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder Name="/Domain/">
|
<Folder Name="/Domain/">
|
||||||
<Project Path="Domain/Domain.Entities/Domain.Entities.csproj"/>
|
<Project Path="Domain/Domain.Entities/Domain.Entities.csproj" />
|
||||||
<Project Path="Domain/Domain.Exceptions/Domain.Exceptions.csproj"/>
|
<Project Path="Domain/Domain.Exceptions/Domain.Exceptions.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder Name="/Infrastructure/">
|
<Folder Name="/Infrastructure/">
|
||||||
<Project Path="Infrastructure/Infrastructure.Email/Infrastructure.Email.csproj"/>
|
<Project Path="Infrastructure/Infrastructure.Email/Infrastructure.Email.csproj" />
|
||||||
<Project
|
<Project Path="Infrastructure/Infrastructure.Email.Templates/Infrastructure.Email.Templates.csproj" />
|
||||||
Path="Infrastructure/Infrastructure.Email.Templates/Infrastructure.Email.Templates.csproj"/>
|
<Project Path="Infrastructure/Infrastructure.Jwt/Infrastructure.Jwt.csproj" />
|
||||||
<Project Path="Infrastructure/Infrastructure.Jwt/Infrastructure.Jwt.csproj"/>
|
<Project Path="Infrastructure/Infrastructure.PasswordHashing/Infrastructure.PasswordHashing.csproj" />
|
||||||
<Project
|
<Project Path="Infrastructure/Infrastructure.Sql/Infrastructure.Sql.csproj" />
|
||||||
Path="Infrastructure/Infrastructure.PasswordHashing/Infrastructure.PasswordHashing.csproj"/>
|
|
||||||
<Project Path="Infrastructure/Infrastructure.Sql/Infrastructure.Sql.csproj"/>
|
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder Name="/Features/">
|
<Folder Name="/Features/">
|
||||||
<Project Path="Features/Features.Breweries/Features.Breweries.csproj"/>
|
<Project Path="Features/Features.Breweries/Features.Breweries.csproj" />
|
||||||
<Project Path="Features/Features.Breweries.Tests/Features.Breweries.Tests.csproj"/>
|
<Project Path="Features/Features.Breweries.Tests/Features.Breweries.Tests.csproj" />
|
||||||
<Project Path="Features/Features.UserManagement/Features.UserManagement.csproj"/>
|
<Project Path="Features/Features.UserManagement/Features.UserManagement.csproj" />
|
||||||
<Project Path="Features/Features.UserManagement.Tests/Features.UserManagement.Tests.csproj"/>
|
<Project Path="Features/Features.UserManagement.Tests/Features.UserManagement.Tests.csproj" />
|
||||||
<Project Path="Features/Features.Auth/Features.Auth.csproj"/>
|
<Project Path="Features/Features.Auth/Features.Auth.csproj" />
|
||||||
<Project Path="Features/Features.Auth.Tests/Features.Auth.Tests.csproj"/>
|
<Project Path="Features/Features.Auth.Tests/Features.Auth.Tests.csproj" />
|
||||||
<Project Path="Features/Features.Emails/Features.Emails.csproj"/>
|
<Project Path="Features/Features.Emails/Features.Emails.csproj" />
|
||||||
<Project Path="Features/Features.Emails.Tests/Features.Emails.Tests.csproj"/>
|
<Project Path="Features/Features.Emails.Tests/Features.Emails.Tests.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
<Folder Name="/Shared/">
|
<Folder Name="/Shared/">
|
||||||
<Project Path="Shared/Shared.Contracts/Shared.Contracts.csproj"/>
|
<Project Path="Shared/Shared.Contracts/Shared.Contracts.csproj" />
|
||||||
<Project Path="Shared/Shared.Application/Shared.Application.csproj"/>
|
<Project Path="Shared/Shared.Application/Shared.Application.csproj" />
|
||||||
</Folder>
|
</Folder>
|
||||||
</Solution>
|
</Solution>
|
||||||
|
|||||||
@@ -180,8 +180,7 @@ public static class Program
|
|||||||
!bool.TryParse(
|
!bool.TryParse(
|
||||||
Environment.GetEnvironmentVariable("DB_TRUST_SERVER_CERTIFICATE"),
|
Environment.GetEnvironmentVariable("DB_TRUST_SERVER_CERTIFICATE"),
|
||||||
out bool parsedTrust
|
out bool parsedTrust
|
||||||
)
|
) || parsedTrust;
|
||||||
|| parsedTrust;
|
|
||||||
|
|
||||||
bool clearDatabase = string.Equals(
|
bool clearDatabase = string.Equals(
|
||||||
Environment.GetEnvironmentVariable("CLEAR_DATABASE"),
|
Environment.GetEnvironmentVariable("CLEAR_DATABASE"),
|
||||||
@@ -204,7 +203,7 @@ public static class Program
|
|||||||
UserID = user,
|
UserID = user,
|
||||||
Password = password,
|
Password = password,
|
||||||
Encrypt = true,
|
Encrypt = true,
|
||||||
TrustServerCertificate = trustServerCertificate
|
TrustServerCertificate = trustServerCertificate,
|
||||||
}.ConnectionString;
|
}.ConnectionString;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -214,4 +213,4 @@ public static class Program
|
|||||||
$"The {variableName} environment variable is not set."
|
$"The {variableName} environment variable is not set."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,8 +21,7 @@
|
|||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\Domain\Domain.Entities\Domain.Entities.csproj" />
|
<ProjectReference Include="..\..\Domain\Domain.Entities\Domain.Entities.csproj" />
|
||||||
<ProjectReference
|
<ProjectReference Include="..\..\Infrastructure\Infrastructure.Sql\Infrastructure.Sql.csproj" />
|
||||||
Include="..\..\Infrastructure\Infrastructure.Sql\Infrastructure.Sql.csproj" />
|
|
||||||
<ProjectReference Include="..\..\Features\Features.Breweries\Features.Breweries.csproj" />
|
<ProjectReference Include="..\..\Features\Features.Breweries\Features.Breweries.csproj" />
|
||||||
<ProjectReference Include="..\..\Features\Features.Auth\Features.Auth.csproj" />
|
<ProjectReference Include="..\..\Features\Features.Auth\Features.Auth.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
@@ -30,7 +29,9 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<!-- Pipeline-generated seed data, copied to the output directory so it can be opened via
|
<!-- Pipeline-generated seed data, copied to the output directory so it can be opened via
|
||||||
ConnectionStrings.SqliteConnectionString at runtime. -->
|
ConnectionStrings.SqliteConnectionString at runtime. -->
|
||||||
<None CopyToOutputDirectory="PreserveNewest"
|
<None
|
||||||
Include="SeedData\biergarten_seed_2026-07-20T05-46-02.993511Z.sqlite" />
|
CopyToOutputDirectory="PreserveNewest"
|
||||||
|
Include="SeedData\biergarten_seed_2026-07-20T05-46-02.993511Z.sqlite"
|
||||||
|
/>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ namespace Database.Seed.DatabaseHelpers;
|
|||||||
public class ConnectionStrings
|
public class ConnectionStrings
|
||||||
{
|
{
|
||||||
public static string SqlServerConnectionString => GetSqlServerConnectionString();
|
public static string SqlServerConnectionString => GetSqlServerConnectionString();
|
||||||
public static string SqliteConnectionString => "Data Source=SeedData/biergarten_seed_2026-07-20T05-46-02.993511Z.sqlite";
|
public static string SqliteConnectionString =>
|
||||||
|
"Data Source=SeedData/biergarten_seed_2026-07-20T05-46-02.993511Z.sqlite";
|
||||||
|
|
||||||
private static string GetSqlServerConnectionString()
|
private static string GetSqlServerConnectionString()
|
||||||
{
|
{
|
||||||
@@ -39,7 +40,7 @@ public class ConnectionStrings
|
|||||||
UserID = user,
|
UserID = user,
|
||||||
Password = password,
|
Password = password,
|
||||||
TrustServerCertificate = bool.Parse(trustServerCertificate),
|
TrustServerCertificate = bool.Parse(trustServerCertificate),
|
||||||
Encrypt = true
|
Encrypt = true,
|
||||||
};
|
};
|
||||||
|
|
||||||
return builder.ConnectionString;
|
return builder.ConnectionString;
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ public sealed record BreweryAddress
|
|||||||
public required City City { get; init; }
|
public required City City { get; init; }
|
||||||
|
|
||||||
public required string PostalCode { get; init; }
|
public required string PostalCode { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ public sealed record BreweryRecord
|
|||||||
public required BreweryAddress Address { get; init; }
|
public required BreweryAddress Address { get; init; }
|
||||||
|
|
||||||
public required BreweryResult Brewery { get; init; }
|
public required BreweryResult Brewery { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ public sealed record BreweryResult
|
|||||||
public required string NameLocal { get; init; }
|
public required string NameLocal { get; init; }
|
||||||
|
|
||||||
public required string DescriptionLocal { get; init; }
|
public required string DescriptionLocal { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,4 +15,4 @@ public sealed record City
|
|||||||
public IReadOnlyList<string> LocalLanguages { get; init; } = [];
|
public IReadOnlyList<string> LocalLanguages { get; init; } = [];
|
||||||
|
|
||||||
public required PostalCodeSpec PostalCode { get; init; }
|
public required PostalCodeSpec PostalCode { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,4 +7,4 @@ public sealed record PostalCodeSpec
|
|||||||
public IReadOnlyList<string> CityRegexes { get; init; } = [];
|
public IReadOnlyList<string> CityRegexes { get; init; } = [];
|
||||||
|
|
||||||
public IReadOnlyList<string> Examples { get; init; } = [];
|
public IReadOnlyList<string> Examples { get; init; } = [];
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -5,4 +5,4 @@ public sealed record UserAddress
|
|||||||
public required City City { get; init; }
|
public required City City { get; init; }
|
||||||
|
|
||||||
public required string PostalCode { get; init; }
|
public required string PostalCode { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,4 +9,4 @@ public sealed record UserRecord
|
|||||||
public required string Email { get; init; }
|
public required string Email { get; init; }
|
||||||
|
|
||||||
public required string DateOfBirth { get; init; }
|
public required string DateOfBirth { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,4 @@ public sealed record UserResult
|
|||||||
public required string Bio { get; init; }
|
public required string Bio { get; init; }
|
||||||
|
|
||||||
public required float ActivityWeight { get; init; }
|
public required float ActivityWeight { get; init; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,23 +1,20 @@
|
|||||||
|
|
||||||
|
|
||||||
using Database.Seed.DatabaseHelpers;
|
using Database.Seed.DatabaseHelpers;
|
||||||
using Database.Seed.PipelineData;
|
using Database.Seed.PipelineData;
|
||||||
using Database.Seed.Sqlite;
|
using Database.Seed.Sqlite;
|
||||||
|
using Domain.Entities;
|
||||||
using Features.Auth.DependencyInjection;
|
using Features.Auth.DependencyInjection;
|
||||||
using Features.Auth.Dtos;
|
using Features.Auth.Dtos;
|
||||||
using Features.Auth.Repository;
|
using Features.Auth.Repository;
|
||||||
using Features.Breweries.DependencyInjection;
|
using Features.Breweries.DependencyInjection;
|
||||||
using Features.Breweries.Repository;
|
using Features.Breweries.Repository;
|
||||||
|
using idunno.Password;
|
||||||
|
using Infrastructure.PasswordHashing;
|
||||||
using Infrastructure.Sql;
|
using Infrastructure.Sql;
|
||||||
using Microsoft.Data.Sqlite;
|
using Microsoft.Data.Sqlite;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
using Microsoft.Extensions.DependencyInjection;
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
using idunno.Password;
|
|
||||||
using Infrastructure.PasswordHashing;
|
|
||||||
using Domain.Entities;
|
|
||||||
|
|
||||||
|
static async Task<int> main()
|
||||||
async static Task<int> main()
|
|
||||||
{
|
{
|
||||||
IReadOnlyList<BreweryRecord> breweries;
|
IReadOnlyList<BreweryRecord> breweries;
|
||||||
IReadOnlyList<UserRecord> users;
|
IReadOnlyList<UserRecord> users;
|
||||||
@@ -61,16 +58,15 @@ async static Task<int> main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
Console.WriteLine(
|
Console.WriteLine($"Loaded {breweries.Count} breweries.");
|
||||||
$"Loaded {breweries.Count} breweries."
|
|
||||||
);
|
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
|
|
||||||
for (int i = 0; i < breweries.Count; i++)
|
for (int i = 0; i < breweries.Count; i++)
|
||||||
{
|
{
|
||||||
BreweryRecord brewery = breweries[i];
|
BreweryRecord brewery = breweries[i];
|
||||||
Console.WriteLine(
|
Console.WriteLine(
|
||||||
$"{i + 1}:\t{brewery.Brewery.NameEn}\t({brewery.Address.City.CityName}, {brewery.Address.City.Country})");
|
$"{i + 1}:\t{brewery.Brewery.NameEn}\t({brewery.Address.City.CityName}, {brewery.Address.City.Country})"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Console.ForegroundColor = ConsoleColor.Green;
|
Console.ForegroundColor = ConsoleColor.Green;
|
||||||
@@ -87,7 +83,11 @@ async static Task<int> main()
|
|||||||
|
|
||||||
// Generate a password that is 64 characters long with 10 digits, 10 symbols,
|
// Generate a password that is 64 characters long with 10 digits, 10 symbols,
|
||||||
// allowing upper and lower case letters, disallowing repeat characters.
|
// allowing upper and lower case letters, disallowing repeat characters.
|
||||||
string generatedPassword = PasswordGenerator.Generate(length: 64, numberOfDigits: 10, numberOfSymbols: 10);
|
string generatedPassword = PasswordGenerator.Generate(
|
||||||
|
length: 64,
|
||||||
|
numberOfDigits: 10,
|
||||||
|
numberOfSymbols: 10
|
||||||
|
);
|
||||||
string hashedPassword = passwordInfrastructure.Hash(generatedPassword);
|
string hashedPassword = passwordInfrastructure.Hash(generatedPassword);
|
||||||
|
|
||||||
UserRegistrationDto registrationDto = new(
|
UserRegistrationDto registrationDto = new(
|
||||||
@@ -102,7 +102,9 @@ async static Task<int> main()
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
UserAccount createdUser = await authRepository.RegisterUserAsync(registrationDto);
|
UserAccount createdUser = await authRepository.RegisterUserAsync(registrationDto);
|
||||||
Console.WriteLine($"Created user: {createdUser.Username} ({createdUser.UserAccountId})");
|
Console.WriteLine(
|
||||||
|
$"Created user: {createdUser.Username} ({createdUser.UserAccountId})"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@@ -110,11 +112,9 @@ async static Task<int> main()
|
|||||||
Console.WriteLine($"Error creating user {username}: {ex.Message}");
|
Console.WriteLine($"Error creating user {username}: {ex.Message}");
|
||||||
Console.ResetColor();
|
Console.ResetColor();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return await main();
|
return await main();
|
||||||
|
|||||||
@@ -25,11 +25,11 @@ public sealed class PipelineSeedDataReader
|
|||||||
IReadOnlyDictionary<long, City> cities = ReadCities(connection);
|
IReadOnlyDictionary<long, City> cities = ReadCities(connection);
|
||||||
|
|
||||||
const string sql = """
|
const string sql = """
|
||||||
SELECT b.name_en, b.description_en, b.name_local, b.description_local,
|
SELECT b.name_en, b.description_en, b.name_local, b.description_local,
|
||||||
ba.city_id, ba.postal_code
|
ba.city_id, ba.postal_code
|
||||||
FROM breweries b
|
FROM breweries b
|
||||||
JOIN brewery_addresses ba ON ba.brewery_id = b.id;
|
JOIN brewery_addresses ba ON ba.brewery_id = b.id;
|
||||||
""";
|
""";
|
||||||
|
|
||||||
using SqliteCommand command = new(sql, connection);
|
using SqliteCommand command = new(sql, connection);
|
||||||
using SqliteDataReader reader = command.ExecuteReader();
|
using SqliteDataReader reader = command.ExecuteReader();
|
||||||
@@ -44,13 +44,13 @@ public sealed class PipelineSeedDataReader
|
|||||||
NameEn = reader.GetString(0),
|
NameEn = reader.GetString(0),
|
||||||
DescriptionEn = reader.GetString(1),
|
DescriptionEn = reader.GetString(1),
|
||||||
NameLocal = reader.GetString(2),
|
NameLocal = reader.GetString(2),
|
||||||
DescriptionLocal = reader.GetString(3)
|
DescriptionLocal = reader.GetString(3),
|
||||||
},
|
},
|
||||||
Address = new BreweryAddress
|
Address = new BreweryAddress
|
||||||
{
|
{
|
||||||
City = cities[reader.GetInt64(4)],
|
City = cities[reader.GetInt64(4)],
|
||||||
PostalCode = reader.GetString(5)
|
PostalCode = reader.GetString(5),
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -65,12 +65,12 @@ public sealed class PipelineSeedDataReader
|
|||||||
IReadOnlyDictionary<long, City> cities = ReadCities(connection);
|
IReadOnlyDictionary<long, City> cities = ReadCities(connection);
|
||||||
|
|
||||||
const string sql = """
|
const string sql = """
|
||||||
SELECT u.first_name, u.last_name, u.gender, u.username, u.bio,
|
SELECT u.first_name, u.last_name, u.gender, u.username, u.bio,
|
||||||
u.activity_weight, u.email, u.date_of_birth,
|
u.activity_weight, u.email, u.date_of_birth,
|
||||||
ua.city_id, ua.postal_code
|
ua.city_id, ua.postal_code
|
||||||
FROM users u
|
FROM users u
|
||||||
JOIN user_addresses ua ON ua.user_id = u.id;
|
JOIN user_addresses ua ON ua.user_id = u.id;
|
||||||
""";
|
""";
|
||||||
|
|
||||||
using SqliteCommand command = new(sql, connection);
|
using SqliteCommand command = new(sql, connection);
|
||||||
using SqliteDataReader reader = command.ExecuteReader();
|
using SqliteDataReader reader = command.ExecuteReader();
|
||||||
@@ -87,15 +87,15 @@ public sealed class PipelineSeedDataReader
|
|||||||
Gender = reader.GetString(2),
|
Gender = reader.GetString(2),
|
||||||
Username = reader.GetString(3),
|
Username = reader.GetString(3),
|
||||||
Bio = reader.GetString(4),
|
Bio = reader.GetString(4),
|
||||||
ActivityWeight = (float)reader.GetDouble(5)
|
ActivityWeight = (float)reader.GetDouble(5),
|
||||||
},
|
},
|
||||||
Email = reader.GetString(6),
|
Email = reader.GetString(6),
|
||||||
DateOfBirth = reader.GetString(7),
|
DateOfBirth = reader.GetString(7),
|
||||||
Address = new UserAddress
|
Address = new UserAddress
|
||||||
{
|
{
|
||||||
City = cities[reader.GetInt64(8)],
|
City = cities[reader.GetInt64(8)],
|
||||||
PostalCode = reader.GetString(9)
|
PostalCode = reader.GetString(9),
|
||||||
}
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -105,18 +105,18 @@ public sealed class PipelineSeedDataReader
|
|||||||
private static IReadOnlyDictionary<long, City> ReadCities(SqliteConnection connection)
|
private static IReadOnlyDictionary<long, City> ReadCities(SqliteConnection connection)
|
||||||
{
|
{
|
||||||
const string sql = """
|
const string sql = """
|
||||||
SELECT
|
SELECT
|
||||||
id,
|
id,
|
||||||
city,
|
city,
|
||||||
state_province,
|
state_province,
|
||||||
iso3166_2,
|
iso3166_2,
|
||||||
country,
|
country,
|
||||||
iso3166_1,
|
iso3166_1,
|
||||||
local_languages_json,
|
local_languages_json,
|
||||||
postal_code_country_format_regex,
|
postal_code_country_format_regex,
|
||||||
postal_code_city_regex_json
|
postal_code_city_regex_json
|
||||||
FROM cities;
|
FROM cities;
|
||||||
""";
|
""";
|
||||||
|
|
||||||
using SqliteCommand command = new(sql, connection);
|
using SqliteCommand command = new(sql, connection);
|
||||||
using SqliteDataReader reader = command.ExecuteReader();
|
using SqliteDataReader reader = command.ExecuteReader();
|
||||||
@@ -144,14 +144,13 @@ public sealed class PipelineSeedDataReader
|
|||||||
PostalCode = new PostalCodeSpec
|
PostalCode = new PostalCodeSpec
|
||||||
{
|
{
|
||||||
CountryFormatRegex = reader.GetString(countryFormatRegexBindIndex),
|
CountryFormatRegex = reader.GetString(countryFormatRegexBindIndex),
|
||||||
CityRegexes = DeserializeStringArray(reader.GetString(cityRegexesBindIndex))
|
CityRegexes = DeserializeStringArray(reader.GetString(cityRegexesBindIndex)),
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
return cities;
|
return cities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private static IReadOnlyList<string> DeserializeStringArray(string json)
|
private static IReadOnlyList<string> DeserializeStringArray(string json)
|
||||||
{
|
{
|
||||||
return JsonSerializer.Deserialize<List<string>>(json) ?? [];
|
return JsonSerializer.Deserialize<List<string>>(json) ?? [];
|
||||||
|
|||||||
@@ -1,18 +1,17 @@
|
|||||||
namespace Database.Seed;
|
namespace Database.Seed;
|
||||||
|
|
||||||
|
|
||||||
public interface IExportDatabase
|
public interface IExportDatabase
|
||||||
{
|
{
|
||||||
void SeedLocations(IEnumerable<Location> locations);
|
void SeedLocations(IEnumerable<Location> locations);
|
||||||
void SeedUsers(IEnumerable<User> users);
|
void SeedUsers(IEnumerable<User> users);
|
||||||
|
|
||||||
void SeedBreweries(IEnumerable<Brewery> breweries);
|
void SeedBreweries(IEnumerable<Brewery> breweries);
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface IImportDatabase
|
public interface IImportDatabase
|
||||||
{
|
{
|
||||||
IEnumerable<Location> GetLocations();
|
IEnumerable<Location> GetLocations();
|
||||||
IEnumerable<User> GetUsers();
|
IEnumerable<User> GetUsers();
|
||||||
|
|
||||||
IEnumerable<Brewery> GetBreweries();
|
IEnumerable<Brewery> GetBreweries();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,12 +34,14 @@ public class RegisterUserHandler(
|
|||||||
string hashed = passwordInfrastructure.Hash(request.Password);
|
string hashed = passwordInfrastructure.Hash(request.Password);
|
||||||
|
|
||||||
UserAccount createdUser = await authRepo.RegisterUserAsync(
|
UserAccount createdUser = await authRepo.RegisterUserAsync(
|
||||||
new UserRegistrationDto(request.Username,
|
new UserRegistrationDto(
|
||||||
request.FirstName,
|
request.Username,
|
||||||
request.LastName,
|
request.FirstName,
|
||||||
request.Email,
|
request.LastName,
|
||||||
request.DateOfBirth,
|
request.Email,
|
||||||
hashed)
|
request.DateOfBirth,
|
||||||
|
hashed
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
string accessToken = tokenService.GenerateAccessToken(createdUser);
|
string accessToken = tokenService.GenerateAccessToken(createdUser);
|
||||||
|
|||||||
@@ -26,9 +26,7 @@ public class AuthRepository(ISqlConnectionFactory connectionFactory)
|
|||||||
/// subsequent lookup to fail.
|
/// subsequent lookup to fail.
|
||||||
/// </remarks>
|
/// </remarks>
|
||||||
/// <exception cref="Exception">Thrown when the newly registered user cannot be retrieved after registration.</exception>
|
/// <exception cref="Exception">Thrown when the newly registered user cannot be retrieved after registration.</exception>
|
||||||
public async Task<UserAccount> RegisterUserAsync(
|
public async Task<UserAccount> RegisterUserAsync(UserRegistrationDto userRegistrationDto)
|
||||||
UserRegistrationDto userRegistrationDto
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
await using DbConnection connection = await CreateConnection();
|
await using DbConnection connection = await CreateConnection();
|
||||||
await using DbCommand command = connection.CreateCommand();
|
await using DbCommand command = connection.CreateCommand();
|
||||||
@@ -36,8 +34,7 @@ public class AuthRepository(ISqlConnectionFactory connectionFactory)
|
|||||||
command.CommandText = "USP_RegisterUser";
|
command.CommandText = "USP_RegisterUser";
|
||||||
command.CommandType = CommandType.StoredProcedure;
|
command.CommandType = CommandType.StoredProcedure;
|
||||||
|
|
||||||
var (username, firstName, lastName, email, dateOfBirth, passwordHash) =
|
var (username, firstName, lastName, email, dateOfBirth, passwordHash) = userRegistrationDto;
|
||||||
userRegistrationDto;
|
|
||||||
|
|
||||||
AddParameter(command, "@Username", username);
|
AddParameter(command, "@Username", username);
|
||||||
AddParameter(command, "@FirstName", firstName);
|
AddParameter(command, "@FirstName", firstName);
|
||||||
|
|||||||
@@ -2,14 +2,13 @@ using Domain.Entities;
|
|||||||
using Features.Auth.Dtos;
|
using Features.Auth.Dtos;
|
||||||
|
|
||||||
namespace Features.Auth.Repository;
|
namespace Features.Auth.Repository;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Repository for authentication-related database operations including user registration and credential management.
|
/// Repository for authentication-related database operations including user registration and credential management.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public interface IAuthRepository
|
public interface IAuthRepository
|
||||||
{
|
{
|
||||||
Task<UserAccount> RegisterUserAsync(
|
Task<UserAccount> RegisterUserAsync(UserRegistrationDto userRegistrationDto);
|
||||||
UserRegistrationDto userRegistrationDto
|
|
||||||
);
|
|
||||||
|
|
||||||
Task<UserAccount?> GetUserByEmailAsync(string email);
|
Task<UserAccount?> GetUserByEmailAsync(string email);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user