mirror of
https://github.com/Govor-team/Govor.git
synced 2026-07-21 19:54:55 +00:00
AuthController work
This commit is contained in:
@@ -16,10 +16,10 @@ public class UserValidator : IObjectValidator<User>
|
||||
throw new ArgumentNullException(nameof(user));
|
||||
if(user.Id == Guid.Empty)
|
||||
throw new ArgumentException("User ID cannot be empty", nameof(user.Id));
|
||||
if(user.Name is null
|
||||
|| user.Name.Length < MIN_LENGHT_OF_NAME
|
||||
|| user.Name.Length > MAX_LENGHT_OF_NAME)
|
||||
throw new ArgumentException($"Username cannot be empty or less then {MIN_LENGHT_OF_NAME} chars or more then {MAX_LENGHT_OF_NAME}", nameof(user.Name));
|
||||
if(user.Username is null
|
||||
|| user.Username.Length < MIN_LENGHT_OF_NAME
|
||||
|| user.Username.Length > MAX_LENGHT_OF_NAME)
|
||||
throw new ArgumentException($"Username cannot be empty or less then {MIN_LENGHT_OF_NAME} chars or more then {MAX_LENGHT_OF_NAME}", nameof(user.Username));
|
||||
if(user.PasswordHash is null || user.PasswordHash == string.Empty)
|
||||
throw new ArgumentException("Password cannot be empty", nameof(user.PasswordHash));
|
||||
if(user.CreatedOn == DateOnly.MinValue)
|
||||
|
||||
@@ -5,7 +5,7 @@ namespace Govor.Core.Models;
|
||||
public class User
|
||||
{
|
||||
public Guid Id {get; set;}
|
||||
public string Name {get; set;}
|
||||
public string Username {get; set;}
|
||||
public string Description {get; set;}
|
||||
public string PasswordHash {get; set;}
|
||||
public Guid IconId {get; set;}
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
namespace Govor.Core.Repositories.Groups;
|
||||
|
||||
public class IGroupsReader
|
||||
{
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using Govor.Core.Models;
|
||||
|
||||
namespace Govor.Core.Repositories;
|
||||
namespace Govor.Core.Repositories.Users;
|
||||
|
||||
public interface IUsersExist
|
||||
{
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using Govor.Core.Models;
|
||||
|
||||
namespace Govor.Core.Repositories;
|
||||
namespace Govor.Core.Repositories.Users;
|
||||
|
||||
public interface IUsersReader
|
||||
{
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
namespace Govor.Core.Repositories;
|
||||
namespace Govor.Core.Repositories.Users;
|
||||
|
||||
public interface IUsersRepository : IUsersReader, IUsersWriter, IUsersExist
|
||||
{
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
using Govor.Core.Models;
|
||||
|
||||
namespace Govor.Core.Repositories;
|
||||
namespace Govor.Core.Repositories.Users;
|
||||
|
||||
public interface IUsersWriter
|
||||
{
|
||||
@@ -1,7 +1,9 @@
|
||||
using Govor.Core.Models;
|
||||
|
||||
namespace Govor.Core.Services;
|
||||
|
||||
public interface IAccountService
|
||||
{
|
||||
public Task RegistrationAsync(string name, string password);
|
||||
public Task<string> RegistrationAsync(string name, string password);
|
||||
public Task<string> LoginAsync(string name, string password);
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
using Govor.Core.Models;
|
||||
|
||||
namespace Govor.Core.Services;
|
||||
|
||||
public interface IJwtService
|
||||
{
|
||||
string GenerateJwtToken(User user);
|
||||
}
|
||||
Reference in New Issue
Block a user