register command created
This commit is contained in:
@@ -1,6 +0,0 @@
|
|||||||
namespace TimetableDesigner.API.Services.Authentication.DTO;
|
|
||||||
|
|
||||||
public class AuthenticatePasswordRequest
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace TimetableDesigner.API.Services.Authentication.DTO;
|
|
||||||
|
|
||||||
public class AuthenticateResponse
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace TimetableDesigner.API.Services.Authentication.DTO;
|
|
||||||
|
|
||||||
public class AuthenticateTokenRequest
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
namespace TimetableDesigner.API.Services.Authentication.DTO;
|
|
||||||
|
|
||||||
public class RegisterRequest
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -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; }
|
||||||
|
}
|
||||||
@@ -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!;
|
||||||
|
}
|
||||||
@@ -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!;
|
||||||
|
}
|
||||||
@@ -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!;
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
namespace TimetableDesigner.Backend.Services.Authentication.DTO;
|
||||||
|
|
||||||
|
public class RegisterResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
|
|
||||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
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
|
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
|
EndProject
|
||||||
Global
|
Global
|
||||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
using Microsoft.AspNetCore.Http.HttpResults;
|
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
|
public static class Endpoints
|
||||||
{
|
{
|
||||||
@@ -17,9 +18,11 @@ public static class Endpoints
|
|||||||
return app;
|
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)
|
public static async Task<Results<Ok<AuthenticateResponse>, ProblemHttpResult>> AuthenticatePassword(AuthenticatePasswordRequest request)
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
namespace TimetableDesigner.Backend.Services.Authentication.Application.Register;
|
||||||
|
|
||||||
|
public record RegisterCommand(string Email, string Password);
|
||||||
@@ -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;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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);
|
||||||
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
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>
|
public class AccountConfiguration : IEntityTypeConfiguration<Account>
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.EntityFrameworkCore.Metadata.Builders;
|
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>
|
public class RefreshTokenConfiguration : IEntityTypeConfiguration<RefreshToken>
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using Microsoft.EntityFrameworkCore;
|
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
|
public class DatabaseContext : DbContext
|
||||||
{
|
{
|
||||||
@@ -5,11 +5,11 @@ using Microsoft.EntityFrameworkCore.Infrastructure;
|
|||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using TimetableDesigner.API.Services.Authentication.Database;
|
using TimetableDesigner.Backend.Services.Authentication.Database;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
namespace TimetableDesigner.Backend.Services.Authentication.Database.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(DatabaseContext))]
|
[DbContext(typeof(DatabaseContext))]
|
||||||
[Migration("20250924120541_Initial")]
|
[Migration("20250924120541_Initial")]
|
||||||
@@ -25,7 +25,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
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")
|
b.Property<long>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -67,7 +67,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
|||||||
b.ToTable("Accounts");
|
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")
|
b.Property<Guid>("Token")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -98,9 +98,9 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
|||||||
b.ToTable("RefreshTokens");
|
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")
|
.WithMany("RefreshTokens")
|
||||||
.HasForeignKey("AccountId")
|
.HasForeignKey("AccountId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -109,7 +109,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
|||||||
b.Navigation("Account");
|
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");
|
b.Navigation("RefreshTokens");
|
||||||
});
|
});
|
||||||
@@ -4,7 +4,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
|||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
namespace TimetableDesigner.Backend.Services.Authentication.Database.Migrations
|
||||||
{
|
{
|
||||||
/// <inheritdoc />
|
/// <inheritdoc />
|
||||||
public partial class Initial : Migration
|
public partial class Initial : Migration
|
||||||
@@ -4,11 +4,11 @@ using Microsoft.EntityFrameworkCore;
|
|||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
||||||
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
|
||||||
using TimetableDesigner.API.Services.Authentication.Database;
|
using TimetableDesigner.Backend.Services.Authentication.Database;
|
||||||
|
|
||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
namespace TimetableDesigner.Backend.Services.Authentication.Database.Migrations
|
||||||
{
|
{
|
||||||
[DbContext(typeof(DatabaseContext))]
|
[DbContext(typeof(DatabaseContext))]
|
||||||
partial class DatabaseContextModelSnapshot : ModelSnapshot
|
partial class DatabaseContextModelSnapshot : ModelSnapshot
|
||||||
@@ -22,7 +22,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
|||||||
|
|
||||||
NpgsqlModelBuilderExtensions.UseIdentityByDefaultColumns(modelBuilder);
|
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")
|
b.Property<long>("Id")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -64,7 +64,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
|||||||
b.ToTable("Accounts");
|
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")
|
b.Property<Guid>("Token")
|
||||||
.ValueGeneratedOnAdd()
|
.ValueGeneratedOnAdd()
|
||||||
@@ -95,9 +95,9 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
|||||||
b.ToTable("RefreshTokens");
|
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")
|
.WithMany("RefreshTokens")
|
||||||
.HasForeignKey("AccountId")
|
.HasForeignKey("AccountId")
|
||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
@@ -106,7 +106,7 @@ namespace TimetableDesigner.API.Services.Authentication.Database.Migrations
|
|||||||
b.Navigation("Account");
|
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");
|
b.Navigation("RefreshTokens");
|
||||||
});
|
});
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace TimetableDesigner.API.Services.Authentication.Database.Model;
|
namespace TimetableDesigner.Backend.Services.Authentication.Database.Model;
|
||||||
|
|
||||||
public class Account
|
public class Account
|
||||||
{
|
{
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace TimetableDesigner.API.Services.Authentication.Database.Model;
|
namespace TimetableDesigner.Backend.Services.Authentication.Database.Model;
|
||||||
|
|
||||||
public class RefreshToken
|
public class RefreshToken
|
||||||
{
|
{
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using TimetableDesigner.API.Services.Authentication.API;
|
using TimetableDesigner.Backend.Services.Authentication.API;
|
||||||
using TimetableDesigner.API.Services.Authentication.Database;
|
using TimetableDesigner.Backend.Services.Authentication.Database;
|
||||||
|
|
||||||
namespace TimetableDesigner.API.Services.Authentication;
|
namespace TimetableDesigner.Backend.Services.Authentication;
|
||||||
|
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
@@ -21,7 +21,7 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<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>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
Reference in New Issue
Block a user