feat: мультироль
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 9s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 2m6s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 26s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 6s
🚀 Create and publish a Docker image / Detect changes in backend and frontend (push) Successful in 9s
🚀 Create and publish a Docker image / Build & publish backend image (push) Successful in 2m6s
🚀 Create and publish a Docker image / Build & publish frontend image (push) Successful in 26s
🚀 Create and publish a Docker image / Update stack on Portainer (push) Successful in 6s
This commit is contained in:
@@ -5,8 +5,8 @@ namespace UniVerse.Application.DTOs.Auth;
|
||||
public record AuthResponse(string AccessToken, DateTime ExpiresAt, UserAuthDto User);
|
||||
public record AuthResult(AuthResponse Response, string RefreshToken);
|
||||
|
||||
public record UserAuthDto(int Id, string Email, string? DisplayName, UserRole Role);
|
||||
public record UserAuthDto(int Id, string Email, string? DisplayName, IReadOnlyList<UserRole> Roles);
|
||||
|
||||
public record LoginMicrosoftRequest(string AuthorizationCode, string? RedirectUri = null);
|
||||
|
||||
public record DevLoginRequest(string Email, string? DisplayName = null, UserRole Role = UserRole.Student);
|
||||
public record DevLoginRequest(string Email, string? DisplayName = null, IReadOnlyList<UserRole>? Roles = null);
|
||||
|
||||
@@ -7,7 +7,7 @@ public record UserDto(
|
||||
string Email,
|
||||
string? DisplayName,
|
||||
string? AvatarUrl,
|
||||
UserRole Role,
|
||||
IReadOnlyList<UserRole> Roles,
|
||||
bool IsActive,
|
||||
int Xp,
|
||||
int Coins,
|
||||
|
||||
@@ -6,7 +6,7 @@ namespace UniVerse.Application.Interfaces;
|
||||
public interface IAuthService
|
||||
{
|
||||
Task<AuthResult> LoginWithMicrosoftAsync(string authorizationCode, string? redirectUri = null, string? ipAddress = null);
|
||||
Task<AuthResult> DevLoginAsync(string email, string? displayName, Domain.Enums.UserRole role, string? ipAddress = null);
|
||||
Task<AuthResult> DevLoginAsync(string email, string? displayName, IReadOnlyCollection<Domain.Enums.UserRole> roles, string? ipAddress = null);
|
||||
Task<AuthResult> RefreshTokenAsync(string refreshToken);
|
||||
Task RevokeRefreshTokenAsync(string refreshToken);
|
||||
Task<UserDto> GetCurrentUserAsync(int userId);
|
||||
|
||||
@@ -10,6 +10,6 @@ public interface IUserService
|
||||
Task<UserDto> UpdateProfileAsync(int id, UpdateUserRequest request);
|
||||
Task<UserStatsDto> GetStatsAsync(int id);
|
||||
Task<PagedResult<UserDto>> GetAllAsync(UserFilterRequest filter);
|
||||
Task SetRoleAsync(int id, UserRole role);
|
||||
Task SetRolesAsync(int id, IReadOnlyCollection<UserRole> roles);
|
||||
Task SetActiveAsync(int id, bool isActive);
|
||||
}
|
||||
|
||||
@@ -16,11 +16,11 @@ public static class MappingExtensions
|
||||
// --- User ---
|
||||
public static UserDto ToDto(this User user, int level) => new(
|
||||
user.Id, user.Email, user.DisplayName, user.AvatarUrl,
|
||||
user.Role, user.IsActive, user.Xp, user.Coins, level, user.CreatedAt
|
||||
user.Roles.Select(r => r.Role).OrderBy(r => r).ToList(), user.IsActive, user.Xp, user.Coins, level, user.CreatedAt
|
||||
);
|
||||
|
||||
public static UserAuthDto ToAuthDto(this User user) => new(
|
||||
user.Id, user.Email, user.DisplayName, user.Role
|
||||
user.Id, user.Email, user.DisplayName, user.Roles.Select(r => r.Role).OrderBy(r => r).ToList()
|
||||
);
|
||||
|
||||
// --- Tag ---
|
||||
|
||||
Reference in New Issue
Block a user