Сборка
This commit is contained in:
@@ -1,16 +1,30 @@
|
|||||||
using Knot.Modules.Messaging;
|
using Knot.Modules.Messaging;
|
||||||
using Knot.Shared.Infrastructure;
|
using Knot.Shared.Infrastructure;
|
||||||
using Knot.Modules.Auth;
|
using Knot.Modules.Auth;
|
||||||
|
using Knot.Modules.Auth.Presentation.Endpoints;
|
||||||
using Knot.Modules.Profiles;
|
using Knot.Modules.Profiles;
|
||||||
|
using Knot.Modules.Profiles.Presentation.Endpoints;
|
||||||
using Knot.Modules.Settings;
|
using Knot.Modules.Settings;
|
||||||
|
using Knot.Modules.Settings.Presentation.Endpoints;
|
||||||
using Knot.Modules.Admin;
|
using Knot.Modules.Admin;
|
||||||
using Knot.Modules.Conversations;
|
using Knot.Modules.Conversations;
|
||||||
using Knot.Modules.Conversations.Infrastructure.SignalR;
|
using Knot.Modules.Conversations.Infrastructure.SignalR;
|
||||||
|
using Knot.Modules.Conversations.Presentation.Endpoints;
|
||||||
using Knot.Modules.Auth.Infrastructure.Persistence;
|
using Knot.Modules.Auth.Infrastructure.Persistence;
|
||||||
using Knot.Modules.Conversations.Infrastructure.Persistence;
|
using Knot.Modules.Conversations.Infrastructure.Persistence;
|
||||||
using Knot.Modules.Storage;
|
using Knot.Modules.Storage;
|
||||||
using Knot.Modules.Stories;
|
using Knot.Modules.Stories;
|
||||||
|
using Knot.Modules.Stories.Presentation.Endpoints;
|
||||||
using Knot.Modules.Klipy;
|
using Knot.Modules.Klipy;
|
||||||
|
using Knot.Modules.Federation;
|
||||||
|
using Knot.Modules.WebRtc;
|
||||||
|
using Knot.Modules.WebRtc.Presentation.Endpoints;
|
||||||
|
using Knot.Modules.TelegramImport;
|
||||||
|
using Knot.Modules.TelegramImport.Presentation.Endpoints;
|
||||||
|
using Knot.Modules.Relations;
|
||||||
|
using Knot.Modules.Relations.Presentation.Endpoints;
|
||||||
|
using Host.Endpoints;
|
||||||
|
using Knot.Host.Presentation.Endpoints;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
using Microsoft.AspNetCore.Authentication.JwtBearer;
|
||||||
using Microsoft.IdentityModel.Tokens;
|
using Microsoft.IdentityModel.Tokens;
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
using Knot.Shared.Kernel;
|
|
||||||
using Knot.Contracts.Auth.Domain;
|
|
||||||
using Knot.Contracts.Auth.Application.Auth.DTOs;
|
using Knot.Contracts.Auth.Application.Auth.DTOs;
|
||||||
|
using Knot.Contracts.Auth.Application.Auth.DTOs;
|
||||||
|
using Knot.Shared.Kernel;
|
||||||
|
|
||||||
namespace Knot.Modules.Auth.Application.Users.GetMe;
|
namespace Knot.Modules.Auth.Application.Users.GetMe;
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
using BCrypt.Net;
|
using BCrypt.Net;
|
||||||
using Knot.Contracts.Auth.Application.Abstractions;
|
using Knot.Contracts.Auth.Application.Abstractions;
|
||||||
using Knot.Contracts.Auth.Application.Auth.DTOs;
|
using Knot.Contracts.Auth.Application.Auth.DTOs;
|
||||||
using Knot.Contracts.Auth.Domain;
|
|
||||||
using Knot.Shared.Kernel;
|
using Knot.Shared.Kernel;
|
||||||
|
|
||||||
namespace Knot.Modules.Auth.Application.Users.Login;
|
namespace Knot.Modules.Auth.Application.Users.Login;
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
using Knot.Contracts.Auth.Domain;
|
using BCrypt.Net;
|
||||||
|
using BCrypt.Net;
|
||||||
using Knot.Contracts.Auth.Application.Abstractions;
|
using Knot.Contracts.Auth.Application.Abstractions;
|
||||||
using Knot.Contracts.Auth.Application.Auth.DTOs;
|
using Knot.Contracts.Auth.Application.Auth.DTOs;
|
||||||
using Knot.Modules.Auth.Domain;
|
|
||||||
using Knot.Shared.Kernel;
|
|
||||||
using Knot.Contracts.Settings.Application.Abstractions;
|
using Knot.Contracts.Settings.Application.Abstractions;
|
||||||
using Knot.Contracts.Settings.Application.DTOs;
|
using Knot.Contracts.Settings.Application.DTOs;
|
||||||
using BCrypt.Net;
|
using Knot.Modules.Auth.Domain;
|
||||||
|
using Knot.Shared.Kernel;
|
||||||
|
|
||||||
namespace Knot.Modules.Auth.Application.Users.Register;
|
namespace Knot.Modules.Auth.Application.Users.Register;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Êîìàíäà äëÿ ðåãèñòðàöèè íîâîãî ïîëüçîâàòåëÿ.
|
/// ������� ��� ����������� ������ ������������.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed record RegisterUserCommand(
|
public sealed record RegisterUserCommand(
|
||||||
string Username,
|
string Username,
|
||||||
@@ -20,7 +20,7 @@ public sealed record RegisterUserCommand(
|
|||||||
string? Bio) : ICommand<AuthResponseDto>;
|
string? Bio) : ICommand<AuthResponseDto>;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Îáðàáîò÷èê êîìàíäû ðåãèñòðàöèè.
|
/// ���������� ������� �����������.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal sealed class RegisterUserCommandHandler : ICommandHandler<RegisterUserCommand, AuthResponseDto>
|
internal sealed class RegisterUserCommandHandler : ICommandHandler<RegisterUserCommand, AuthResponseDto>
|
||||||
{
|
{
|
||||||
@@ -48,16 +48,16 @@ internal sealed class RegisterUserCommandHandler : ICommandHandler<RegisterUserC
|
|||||||
return Result.Failure<AuthResponseDto>(AuthErrors.IdentityRegistrationDisabled);
|
return Result.Failure<AuthResponseDto>(AuthErrors.IdentityRegistrationDisabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 1. Ïðîâåðêà óíèêàëüíîñòè username
|
// 1. �������� ������������ username
|
||||||
if (!await _userRepository.IsUsernameUniqueAsync(request.Username, cancellationToken))
|
if (!await _userRepository.IsUsernameUniqueAsync(request.Username, cancellationToken))
|
||||||
{
|
{
|
||||||
return Result.Failure<AuthResponseDto>(AuthErrors.IdentityUsernameNotUnique);
|
return Result.Failure<AuthResponseDto>(AuthErrors.IdentityUsernameNotUnique);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 2. Õåøèðîâàíèå ïàðîëÿ
|
// 2. ����������� ������
|
||||||
string passwordHash = BCrypt.Net.BCrypt.HashPassword(request.Password);
|
string passwordHash = BCrypt.Net.BCrypt.HashPassword(request.Password);
|
||||||
|
|
||||||
// 3. Ñîçäàíèå ñóùíîñòè
|
// 3. �������� ��������
|
||||||
var user = User.Create(
|
var user = User.Create(
|
||||||
request.Username,
|
request.Username,
|
||||||
passwordHash,
|
passwordHash,
|
||||||
@@ -65,7 +65,7 @@ internal sealed class RegisterUserCommandHandler : ICommandHandler<RegisterUserC
|
|||||||
request.Email,
|
request.Email,
|
||||||
request.Bio);
|
request.Bio);
|
||||||
|
|
||||||
// 4. Ñîõðàíåíèå - èñïîëüçóåì ìåòîä ñ Domain User
|
// 4. ���������� - ���������� ����� � Domain User
|
||||||
var repoWithDomainUserAdd = _userRepository as Infrastructure.Persistence.UserRepository;
|
var repoWithDomainUserAdd = _userRepository as Infrastructure.Persistence.UserRepository;
|
||||||
repoWithDomainUserAdd?.Add(user);
|
repoWithDomainUserAdd?.Add(user);
|
||||||
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ public static class DependencyInjection
|
|||||||
services.AddScoped<IAuthUnitOfWork>(sp => sp.GetRequiredService<AuthDbContext>());
|
services.AddScoped<IAuthUnitOfWork>(sp => sp.GetRequiredService<AuthDbContext>());
|
||||||
services.AddScoped<Knot.Contracts.Auth.Application.Abstractions.IAuthDbContext>(sp => sp.GetRequiredService<AuthDbContext>());
|
services.AddScoped<Knot.Contracts.Auth.Application.Abstractions.IAuthDbContext>(sp => sp.GetRequiredService<AuthDbContext>());
|
||||||
services.AddScoped<Knot.Contracts.Auth.Infrastructure.Persistence.IAuthDbContext>(sp => sp.GetRequiredService<AuthDbContext>());
|
services.AddScoped<Knot.Contracts.Auth.Infrastructure.Persistence.IAuthDbContext>(sp => sp.GetRequiredService<AuthDbContext>());
|
||||||
services.AddScoped<IUserRepository, UserRepository>();
|
services.AddScoped<Knot.Contracts.Auth.Domain.IUserRepository, UserRepository>();
|
||||||
services.AddScoped<IJwtTokenProvider, JwtTokenProvider>();
|
services.AddScoped<IJwtTokenProvider, JwtTokenProvider>();
|
||||||
services.AddScoped<IUserDisplayNameProvider, Knot.Modules.Auth.Infrastructure.Services.UserDisplayNameProvider>();
|
services.AddScoped<IUserDisplayNameProvider, Knot.Modules.Auth.Infrastructure.Services.UserDisplayNameProvider>();
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
using Knot.Modules.Auth.Domain;
|
|
||||||
|
|
||||||
namespace Knot.Modules.Auth.Domain;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Интерфейс репозитория для работы с пользователями.
|
|
||||||
/// </summary>
|
|
||||||
public interface IUserRepository
|
|
||||||
{
|
|
||||||
Task<User?> GetByIdAsync(Guid id, CancellationToken cancellationToken = default);
|
|
||||||
Task<List<User>> GetByIdsAsync(IEnumerable<Guid> ids, CancellationToken cancellationToken = default);
|
|
||||||
Task<User?> GetByUsernameAsync(string username, CancellationToken cancellationToken = default);
|
|
||||||
Task<bool> IsUsernameUniqueAsync(string username, CancellationToken cancellationToken = default);
|
|
||||||
Task<List<User>> SearchUsersAsync(string query, CancellationToken cancellationToken = default);
|
|
||||||
void Add(User user);
|
|
||||||
void Update(User user);
|
|
||||||
void Remove(User user);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
// Глобальные алиасы для модуля Auth
|
||||||
|
// Используем контракты вместо дублирующихся интерфейсов из модуля
|
||||||
|
global using AuthErrors = Knot.Contracts.Auth.Application.Auth.DTOs.AuthErrors;
|
||||||
|
global using IUserRepository = Knot.Contracts.Auth.Domain.IUserRepository;
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
using Knot.Contracts.Auth.Domain;
|
|
||||||
using Knot.Shared.Kernel;
|
using Knot.Shared.Kernel;
|
||||||
|
|
||||||
namespace Knot.Modules.Auth.Infrastructure.Services;
|
namespace Knot.Modules.Auth.Infrastructure.Services;
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ public static class DependencyInjection
|
|||||||
{
|
{
|
||||||
public static IServiceCollection AddProfilesModule(this IServiceCollection services, IConfiguration configuration)
|
public static IServiceCollection AddProfilesModule(this IServiceCollection services, IConfiguration configuration)
|
||||||
{
|
{
|
||||||
services.AddScoped<IProfileRepository, ProfileRepository>();
|
services.AddScoped<Knot.Contracts.Profiles.Domain.IProfileRepository, ProfileRepository>();
|
||||||
services.AddScoped<IProfilesUnitOfWork, ProfilesUnitOfWork>();
|
services.AddScoped<Knot.Contracts.Profiles.Domain.IProfilesUnitOfWork, ProfilesUnitOfWork>();
|
||||||
services.AddScoped<IAvatarStorageService, AvatarStorageService>();
|
services.AddScoped<Knot.Contracts.Profiles.Domain.IAvatarStorageService, AvatarStorageService>();
|
||||||
|
|
||||||
// MongoDB Registration
|
// MongoDB Registration
|
||||||
var mongoConnection = configuration.GetConnectionString("MongoConnection")
|
var mongoConnection = configuration.GetConnectionString("MongoConnection")
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
using System.IO;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Knot.Modules.Profiles.Domain;
|
|
||||||
|
|
||||||
public interface IAvatarStorageService
|
|
||||||
{
|
|
||||||
Task<string> UploadAsync(Stream content, string fileName, string contentType, CancellationToken ct = default);
|
|
||||||
Task DeleteAsync(string fileId, CancellationToken ct = default);
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Knot.Modules.Profiles.Domain;
|
|
||||||
|
|
||||||
public interface IProfileRepository
|
|
||||||
{
|
|
||||||
Task<ProfileDocument?> GetByIdAsync(Guid id, CancellationToken ct = default);
|
|
||||||
Task<ProfileDocument?> GetByUsernameAsync(string username, CancellationToken ct = default);
|
|
||||||
Task AddAsync(ProfileDocument profile, CancellationToken ct = default);
|
|
||||||
Task UpdateAsync(ProfileDocument profile, CancellationToken ct = default);
|
|
||||||
Task<List<ProfileDocument>> SearchAsync(string query, CancellationToken ct = default);
|
|
||||||
}
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
using System.Threading;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace Knot.Modules.Profiles.Domain;
|
|
||||||
|
|
||||||
public interface IProfilesUnitOfWork
|
|
||||||
{
|
|
||||||
Task SaveChangesAsync(CancellationToken ct = default);
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
namespace Knot.Modules.Profiles.Domain;
|
|
||||||
using Knot.Shared.Kernel;
|
|
||||||
public static class ProfilesErrors
|
|
||||||
{
|
|
||||||
public static readonly Error ProfileNotFound = new("Profile.NotFound", "Profile not found");
|
|
||||||
}
|
|
||||||
public static class IdentityErrors
|
|
||||||
{
|
|
||||||
public static readonly Error UserNotFound = new("Profile.NotFound", "Profile not found");
|
|
||||||
}
|
|
||||||
@@ -1,18 +1,32 @@
|
|||||||
|
global using System;
|
||||||
|
global using System;
|
||||||
|
global using System.Collections.Generic;
|
||||||
|
global using System.Collections.Generic;
|
||||||
|
global using System.IO;
|
||||||
|
global using System.IO;
|
||||||
|
global using System.Linq;
|
||||||
|
global using System.Linq;
|
||||||
|
global using System.Threading;
|
||||||
|
global using System.Threading;
|
||||||
|
global using System.Threading.Tasks;
|
||||||
|
global using System.Threading.Tasks;
|
||||||
|
global using Knot.Modules.Profiles.Domain;
|
||||||
|
global using Knot.Modules.Profiles.Domain;
|
||||||
|
global using Knot.Modules.Profiles.Domain.Events;
|
||||||
|
global using Knot.Modules.Profiles.Domain.Events;
|
||||||
|
global using Knot.Modules.Profiles.Infrastructure.Database;
|
||||||
|
global using Knot.Modules.Profiles.Infrastructure.Database;
|
||||||
global using Knot.Shared.Kernel;
|
global using Knot.Shared.Kernel;
|
||||||
global using Knot.Shared.Kernel.Events;
|
global using Knot.Shared.Kernel.Events;
|
||||||
global using Knot.Shared.Kernel.Storage;
|
global using Knot.Shared.Kernel.Storage;
|
||||||
global using Knot.Modules.Profiles.Domain;
|
global using MediatR;
|
||||||
global using Knot.Modules.Profiles.Domain.Events;
|
global using Microsoft.Extensions.Configuration;
|
||||||
global using Knot.Modules.Profiles.Infrastructure.Database;
|
global using Microsoft.Extensions.DependencyInjection;
|
||||||
global using MongoDB.Bson;
|
global using MongoDB.Bson;
|
||||||
global using MongoDB.Bson.Serialization.Attributes;
|
global using MongoDB.Bson.Serialization.Attributes;
|
||||||
global using MongoDB.Driver;
|
global using MongoDB.Driver;
|
||||||
global using MediatR;
|
global using IAvatarStorageService = Knot.Contracts.Profiles.Domain.IAvatarStorageService;
|
||||||
global using Microsoft.Extensions.DependencyInjection;
|
// Алиасы для использования контрактов вместо дублирующихся интерфейсов модуля
|
||||||
global using Microsoft.Extensions.Configuration;
|
global using IProfileRepository = Knot.Contracts.Profiles.Domain.IProfileRepository;
|
||||||
global using System;
|
global using IProfilesUnitOfWork = Knot.Contracts.Profiles.Domain.IProfilesUnitOfWork;
|
||||||
global using System.Collections.Generic;
|
global using ProfilesErrors = Knot.Contracts.Profiles.Application.DTOs.ProfilesErrors;
|
||||||
global using System.Threading;
|
|
||||||
global using System.Threading.Tasks;
|
|
||||||
global using System.IO;
|
|
||||||
global using System.Linq;
|
|
||||||
|
|||||||
@@ -3,12 +3,11 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Knot.Contracts.Profiles.Domain;
|
|
||||||
using Knot.Contracts.Profiles.Application.DTOs;
|
using Knot.Contracts.Profiles.Application.DTOs;
|
||||||
|
using Knot.Contracts.Profiles.Domain;
|
||||||
using Knot.Modules.Profiles.Domain;
|
using Knot.Modules.Profiles.Domain;
|
||||||
using Knot.Modules.Profiles.Infrastructure.Mappings;
|
using Knot.Modules.Profiles.Infrastructure.Mappings;
|
||||||
using Knot.Shared.Kernel;
|
using Knot.Shared.Kernel;
|
||||||
using ProfilesErrors = Knot.Contracts.Profiles.Application.DTOs.ProfilesErrors;
|
|
||||||
using MongoDB.Bson;
|
using MongoDB.Bson;
|
||||||
using MongoDB.Driver;
|
using MongoDB.Driver;
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
|
using System;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Knot.Contracts.Relations.Domain;
|
||||||
using Knot.Modules.Stories.Domain;
|
using Knot.Modules.Stories.Domain;
|
||||||
using Knot.Modules.Relations.Domain;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
namespace Knot.Modules.Stories.Application.Abstractions;
|
namespace Knot.Modules.Stories.Application.Abstractions;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user