Registration rework

+ InvitesRepository
+ AdminsRepository
+ rework jwt
This commit is contained in:
Artemy
2025-06-24 14:27:08 +07:00
parent 410a1ce1cc
commit ce013eae49
37 changed files with 2084 additions and 29 deletions
@@ -3,7 +3,7 @@ using Govor.Core.Infrastructure.Validators;
namespace Govor.Core.DTOs;
public record UserDto
public class LoginDto
{
[Required]
[StringLength(UserValidator.MAX_LENGHT_OF_NAME,
+18
View File
@@ -0,0 +1,18 @@
using System.ComponentModel.DataAnnotations;
using Govor.Core.Infrastructure.Validators;
namespace Govor.Core.DTOs;
public record RegistrationDto
{
[Required]
[StringLength(UserValidator.MAX_LENGHT_OF_NAME,
MinimumLength = UserValidator.MIN_LENGHT_OF_NAME,
ErrorMessage = "Username must be between 4 and 50 characters.")]
public string Name { get; init; }
[Required]
[MinLength(8)]
public string Password { get; init; }
[MinLength(8)]
public string InviteLink { get; init; }
}
+10
View File
@@ -0,0 +1,10 @@
using System.ComponentModel.DataAnnotations;
namespace Govor.Core.Models;
public class Admin
{
[Key]
public Guid UserId { get; set; }
public User User { get; set; } = null!;
}
+11
View File
@@ -0,0 +1,11 @@
namespace Govor.Core.Models;
public class Invitation
{
public Guid Id { get; set; }
public bool IsAdmin { get; set; }
public DateTime DateCreated { get; set; }
public DateTime EndDate { get; set; }
public int MaxParticipants { get; set; }
public List<User> Users { get; set; } = new List<User>();
}
+2
View File
@@ -11,4 +11,6 @@ public class User
public Guid IconId {get; set;}
public DateOnly CreatedOn {get; set;}
public DateTime WasOnline {get; set;}
public Guid InviteId {get; set;}
public Invitation? Invite { get; set; }
}
@@ -0,0 +1,9 @@
using Govor.Core.Models;
namespace Govor.Core.Repositories.Admins;
public interface IAdminsExist
{
bool Exist(Guid guid);
bool Exist(Admin admin);
}
@@ -0,0 +1,9 @@
using Govor.Core.Models;
namespace Govor.Core.Repositories.Admins;
public interface IAdminsReader
{
Task<List<Admin>> GetAllAsync();
Task<Admin> GetByIdAsync(Guid id);
}
@@ -0,0 +1,6 @@
namespace Govor.Core.Repositories.Admins;
public interface IAdminsRepository : IAdminsReader, IAdminsWriter, IAdminsExist
{
}
@@ -0,0 +1,10 @@
using Govor.Core.Models;
namespace Govor.Core.Repositories.Admins;
public interface IAdminsWriter
{
Task AddAsync(Admin admin);
Task UpdateAsync(Admin admin);
Task DeleteAsync(Guid admin);
}
@@ -0,0 +1,9 @@
using Govor.Core.Models;
namespace Govor.Core.Repositories.Invaites;
public interface IInvitesExist
{
bool Exist(Invitation invitation);
bool Exist(Guid guid);
}
@@ -0,0 +1,11 @@
using Govor.Core.Models;
namespace Govor.Core.Repositories.Invaites;
public interface IInvitesReader
{
Task<List<Invitation>> GetAllAsync();
Task<Invitation> GetByIdAsync(Guid id);
Task<Invitation> GetByCodeAsync(string code);
Task<List<Invitation>> GetAdminsInvitesAsync();
}
@@ -0,0 +1,6 @@
namespace Govor.Core.Repositories.Invaites;
public interface IInvitesRepository : IInvitesReader, IInvitesWriter, IInvitesExist
{
}
@@ -0,0 +1,10 @@
using Govor.Core.Models;
namespace Govor.Core.Repositories.Invaites;
public interface IInvitesWriter
{
Task AddAsync(Invitation invitation);
Task UpdateAsync(Invitation invitation);
Task RemoveAsync(Invitation invitation);
}