register command created

This commit is contained in:
2026-01-11 02:30:08 +01:00
Unverified
parent 65ba579704
commit 56e66a2bdd
29 changed files with 102 additions and 57 deletions

View File

@@ -1,6 +0,0 @@
namespace TimetableDesigner.API.Services.Authentication.DTO;
public class AuthenticatePasswordRequest
{
}

View File

@@ -1,6 +0,0 @@
namespace TimetableDesigner.API.Services.Authentication.DTO;
public class AuthenticateResponse
{
}

View File

@@ -1,6 +0,0 @@
namespace TimetableDesigner.API.Services.Authentication.DTO;
public class AuthenticateTokenRequest
{
}

View File

@@ -1,6 +0,0 @@
namespace TimetableDesigner.API.Services.Authentication.DTO;
public class RegisterRequest
{
}

View File

@@ -0,0 +1,8 @@
namespace TimetableDesigner.Backend.Services.Authentication.DTO;
public class AuthenticatePasswordRequest
{
public string Email { get; set; } = null!;
public string Password { get; set; } = null!;
public bool RememberMe { get; set; }
}

View File

@@ -0,0 +1,7 @@
namespace TimetableDesigner.Backend.Services.Authentication.DTO;
public class AuthenticateResponse
{
public string AccessToken { get; set; } = null!;
public string RefreshToken { get; set; } = null!;
}

View File

@@ -0,0 +1,7 @@
namespace TimetableDesigner.Backend.Services.Authentication.DTO;
public class AuthenticateTokenRequest
{
public string AccessToken { get; set; } = null!;
public string RefreshToken { get; set; } = null!;
}

View File

@@ -0,0 +1,8 @@
namespace TimetableDesigner.Backend.Services.Authentication.DTO;
public class RegisterRequest
{
public string Email { get; set; } = null!;
public string Password { get; set; } = null!;
public string PasswordConfirmation { get; set; } = null!;
}

View File

@@ -0,0 +1,6 @@
namespace TimetableDesigner.Backend.Services.Authentication.DTO;
public class RegisterResponse
{
}

View File

@@ -1,8 +1,8 @@

Microsoft Visual Studio Solution File, Format Version 12.00
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimetableDesigner.API.Services.Authentication", "TimetableDesigner.API.Services.Authentication/TimetableDesigner.API.Services.Authentication.csproj", "{F8C0AEF3-B53F-4904-90F7-EE4A8587F023}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimetableDesigner.Backend.Services.Authentication", "TimetableDesigner.Backend.Services.Authentication\TimetableDesigner.Backend.Services.Authentication.csproj", "{F8C0AEF3-B53F-4904-90F7-EE4A8587F023}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimetableDesigner.API.Services.Authentication.DTO", "TimetableDesigner.API.Services.Authentication.DTO\TimetableDesigner.API.Services.Authentication.DTO.csproj", "{384C8036-ACA7-40EB-924D-5E0271BEDB09}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TimetableDesigner.Backend.Services.Authentication.DTO", "TimetableDesigner.Backend.Services.Authentication.DTO\TimetableDesigner.Backend.Services.Authentication.DTO.csproj", "{384C8036-ACA7-40EB-924D-5E0271BEDB09}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution

View File

@@ -1,7 +1,8 @@
using Microsoft.AspNetCore.Http.HttpResults;
using TimetableDesigner.API.Services.Authentication.DTO;
using TimetableDesigner.Backend.Services.Authentication.Application.Register;
using TimetableDesigner.Backend.Services.Authentication.DTO;
namespace TimetableDesigner.API.Services.Authentication.API;
namespace TimetableDesigner.Backend.Services.Authentication.API;
public static class Endpoints
{
@@ -17,9 +18,11 @@ public static class Endpoints
return app;
}
public static async Task<Results<Ok<AuthenticateResponse>, ProblemHttpResult>> Register(RegisterRequest request)
public static async Task<Results<Created<RegisterResponse>, ProblemHttpResult>> Register(RegisterRequest request, RegisterHandler handler)
{
return null;
RegisterCommand command = request.ToCommand();
RegisterResponse account = await handler.HandleAsync(command);
return Results.Created($"accounts/{account.Id}", account);
}
public static async Task<Results<Ok<AuthenticateResponse>, ProblemHttpResult>> AuthenticatePassword(AuthenticatePasswordRequest request)

View File

@@ -0,0 +1,3 @@
namespace TimetableDesigner.Backend.Services.Authentication.Application.Register;
public record RegisterCommand(string Email, string Password);

View File

@@ -0,0 +1,19 @@
using TimetableDesigner.Backend.Services.Authentication.Database;
using TimetableDesigner.Backend.Services.Authentication.DTO;
namespace TimetableDesigner.Backend.Services.Authentication.Application.Register;
public class RegisterHandler
{
private readonly DatabaseContext _databaseContext;
public RegisterHandler(DatabaseContext databaseContext)
{
_databaseContext = databaseContext;
}
public async Task<RegisterResponse> HandleAsync(RegisterCommand command)
{
return null;
}
}

View File

@@ -0,0 +1,8 @@
using TimetableDesigner.Backend.Services.Authentication.DTO;
namespace TimetableDesigner.Backend.Services.Authentication.Application.Register;
public static class RegisterRequestMapper
{
public static RegisterCommand ToCommand(this RegisterRequest request) => new RegisterCommand(request.Email, request.Password);
}

View File

@@ -1,8 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TimetableDesigner.API.Services.Authentication.Database.Model;
using TimetableDesigner.Backend.Services.Authentication.Database.Model;
namespace TimetableDesigner.API.Services.Authentication.Database.Configuration;
namespace TimetableDesigner.Backend.Services.Authentication.Database.Configuration;
public class AccountConfiguration : IEntityTypeConfiguration<Account>
{

View File

@@ -1,8 +1,8 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using TimetableDesigner.API.Services.Authentication.Database.Model;
using TimetableDesigner.Backend.Services.Authentication.Database.Model;
namespace TimetableDesigner.API.Services.Authentication.Database.Configuration;
namespace TimetableDesigner.Backend.Services.Authentication.Database.Configuration;
public class RefreshTokenConfiguration : IEntityTypeConfiguration<RefreshToken>
{

View File

@@ -1,8 +1,8 @@
using System.Reflection;
using Microsoft.EntityFrameworkCore;
using TimetableDesigner.API.Services.Authentication.Database.Model;
using TimetableDesigner.Backend.Services.Authentication.Database.Model;
namespace TimetableDesigner.API.Services.Authentication.Database;
namespace TimetableDesigner.Backend.Services.Authentication.Database;
public class DatabaseContext : DbContext
{

View File

@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using TimetableDesigner.API.Services.Authentication.Database;
using TimetableDesigner.Backend.Services.Authentication.Database;
#nullable disable
namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
namespace TimetableDesigner.Backend.Services.Authentication.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
[Migration("20250924120541_Initial")]
@@ -25,7 +25,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TimetableDesigner.API.Services.Authentication.Database.Model.Account", b =>
modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
@@ -67,7 +67,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
b.ToTable("Accounts");
});
modelBuilder.Entity("TimetableDesigner.API.Services.Authentication.Database.Model.RefreshToken", b =>
modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.RefreshToken", b =>
{
b.Property<Guid>("Token")
.ValueGeneratedOnAdd()
@@ -98,9 +98,9 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
b.ToTable("RefreshTokens");
});
modelBuilder.Entity("TimetableDesigner.API.Services.Authentication.Database.Model.RefreshToken", b =>
modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.RefreshToken", b =>
{
b.HasOne("TimetableDesigner.API.Services.Authentication.Database.Model.Account", "Account")
b.HasOne("TimetableDesigner.Backend.Services.Authentication.Database.Model.Account", "Account")
.WithMany("RefreshTokens")
.HasForeignKey("AccountId")
.OnDelete(DeleteBehavior.Cascade)
@@ -109,7 +109,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
b.Navigation("Account");
});
modelBuilder.Entity("TimetableDesigner.API.Services.Authentication.Database.Model.Account", b =>
modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.Account", b =>
{
b.Navigation("RefreshTokens");
});

View File

@@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
namespace TimetableDesigner.Backend.Services.Authentication.Database.Migrations
{
/// <inheritdoc />
public partial class Initial : Migration

View File

@@ -4,11 +4,11 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
using TimetableDesigner.API.Services.Authentication.Database;
using TimetableDesigner.Backend.Services.Authentication.Database;
#nullable disable
namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
namespace TimetableDesigner.Backend.Services.Authentication.Database.Migrations
{
[DbContext(typeof(DatabaseContext))]
partial class DatabaseContextModelSnapshot : ModelSnapshot
@@ -22,7 +22,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
modelBuilder.Entity("TimetableDesigner.API.Services.Authentication.Database.Model.Account", b =>
modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.Account", b =>
{
b.Property<long>("Id")
.ValueGeneratedOnAdd()
@@ -64,7 +64,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
b.ToTable("Accounts");
});
modelBuilder.Entity("TimetableDesigner.API.Services.Authentication.Database.Model.RefreshToken", b =>
modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.RefreshToken", b =>
{
b.Property<Guid>("Token")
.ValueGeneratedOnAdd()
@@ -95,9 +95,9 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
b.ToTable("RefreshTokens");
});
modelBuilder.Entity("TimetableDesigner.API.Services.Authentication.Database.Model.RefreshToken", b =>
modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.RefreshToken", b =>
{
b.HasOne("TimetableDesigner.API.Services.Authentication.Database.Model.Account", "Account")
b.HasOne("TimetableDesigner.Backend.Services.Authentication.Database.Model.Account", "Account")
.WithMany("RefreshTokens")
.HasForeignKey("AccountId")
.OnDelete(DeleteBehavior.Cascade)
@@ -106,7 +106,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
b.Navigation("Account");
});
modelBuilder.Entity("TimetableDesigner.API.Services.Authentication.Database.Model.Account", b =>
modelBuilder.Entity("TimetableDesigner.Backend.Services.Authentication.Database.Model.Account", b =>
{
b.Navigation("RefreshTokens");
});

View File

@@ -1,4 +1,4 @@
namespace TimetableDesigner.API.Services.Authentication.Database.Model;
namespace TimetableDesigner.Backend.Services.Authentication.Database.Model;
public class Account
{

View File

@@ -1,4 +1,4 @@
namespace TimetableDesigner.API.Services.Authentication.Database.Model;
namespace TimetableDesigner.Backend.Services.Authentication.Database.Model;
public class RefreshToken
{

View File

@@ -1,8 +1,8 @@
using Microsoft.EntityFrameworkCore;
using TimetableDesigner.API.Services.Authentication.API;
using TimetableDesigner.API.Services.Authentication.Database;
using TimetableDesigner.Backend.Services.Authentication.API;
using TimetableDesigner.Backend.Services.Authentication.Database;
namespace TimetableDesigner.API.Services.Authentication;
namespace TimetableDesigner.Backend.Services.Authentication;
public static class Program
{

View File

@@ -21,7 +21,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\TimetableDesigner.API.Services.Authentication.DTO\TimetableDesigner.API.Services.Authentication.DTO.csproj" />
<ProjectReference Include="..\TimetableDesigner.Backend.Services.Authentication.DTO\TimetableDesigner.Backend.Services.Authentication.DTO.csproj" />
</ItemGroup>
</Project>