mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
Registration rework
+ InvitesRepository + AdminsRepository + rework jwt
This commit is contained in:
@@ -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,
|
||||
@@ -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; }
|
||||
}
|
||||
@@ -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!;
|
||||
}
|
||||
@@ -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>();
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
Reference in New Issue
Block a user