diff --git a/AnalysisData/AnalysisData/Controllers/GraphController/CategoriesController.cs b/AnalysisData/AnalysisData/Controllers/GraphController/CategoriesController.cs index 0fbf5b6..59b5ddc 100644 --- a/AnalysisData/AnalysisData/Controllers/GraphController/CategoriesController.cs +++ b/AnalysisData/AnalysisData/Controllers/GraphController/CategoriesController.cs @@ -29,7 +29,7 @@ public async Task GetCategories(int pageNumber = 0, int pageSize public async Task GetAllCategoriesWithOutPagination() { var categories = await _categoryService.GetAllCategoriesWithoutPaginationAsync(); - return Ok(categories); + return Ok(categories.Categories); } [Authorize(Policy = "silver")] diff --git a/AnalysisData/AnalysisData/Dtos/GraphDto/CategoryDto/GetAllCategoryDto.cs b/AnalysisData/AnalysisData/Dtos/GraphDto/CategoryDto/GetAllCategoryDto.cs index cebcba3..3358b14 100644 --- a/AnalysisData/AnalysisData/Dtos/GraphDto/CategoryDto/GetAllCategoryDto.cs +++ b/AnalysisData/AnalysisData/Dtos/GraphDto/CategoryDto/GetAllCategoryDto.cs @@ -5,4 +5,9 @@ namespace AnalysisData.Dtos.GraphDto.CategoryDto; public class GetAllCategoryDto { public IEnumerable Categories; + + public GetAllCategoryDto(IEnumerable categories) + { + Categories = categories; + } } \ No newline at end of file diff --git a/AnalysisData/AnalysisData/Repositories/PasswordResetTokensRepository/Abstraction/IPasswordResetTokensRepository.cs b/AnalysisData/AnalysisData/Repositories/PasswordResetTokensRepository/Abstraction/IPasswordResetTokensRepository.cs index bc454c8..2409029 100644 --- a/AnalysisData/AnalysisData/Repositories/PasswordResetTokensRepository/Abstraction/IPasswordResetTokensRepository.cs +++ b/AnalysisData/AnalysisData/Repositories/PasswordResetTokensRepository/Abstraction/IPasswordResetTokensRepository.cs @@ -5,7 +5,7 @@ namespace AnalysisData.Repositories.PasswordResetTokensRepository.Abstraction; public interface IPasswordResetTokensRepository { Task AddToken(PasswordResetToken token); - Task GetToken(Guid guid); + Task GetToken(Guid guid, string token); Task SaveChange(); } \ No newline at end of file diff --git a/AnalysisData/AnalysisData/Repositories/PasswordResetTokensRepository/PasswordResetTokensRepository.cs b/AnalysisData/AnalysisData/Repositories/PasswordResetTokensRepository/PasswordResetTokensRepository.cs index 343b65a..6cf42fb 100644 --- a/AnalysisData/AnalysisData/Repositories/PasswordResetTokensRepository/PasswordResetTokensRepository.cs +++ b/AnalysisData/AnalysisData/Repositories/PasswordResetTokensRepository/PasswordResetTokensRepository.cs @@ -20,10 +20,11 @@ public async Task AddToken(PasswordResetToken token) await _context.SaveChangesAsync(); } - public async Task GetToken(Guid userId) + public async Task GetToken(Guid userId, string token) { - return await _context.Tokens.Include(x => x.User).OrderByDescending(x => x.Id) - .FirstOrDefaultAsync(x => x.UserId == userId); + return await _context.Tokens + .Include(x => x.User) + .FirstOrDefaultAsync(x => x.UserId == userId && x.Token == token); } public async Task SaveChange() diff --git a/AnalysisData/AnalysisData/Services/GraphService/CategoryService/CategoryService.cs b/AnalysisData/AnalysisData/Services/GraphService/CategoryService/CategoryService.cs index 4632ab7..9e51d16 100644 --- a/AnalysisData/AnalysisData/Services/GraphService/CategoryService/CategoryService.cs +++ b/AnalysisData/AnalysisData/Services/GraphService/CategoryService/CategoryService.cs @@ -36,7 +36,7 @@ public async Task GetAllCategoriesAsync(int pageNumber, i public async Task GetAllCategoriesWithoutPaginationAsync() { var allCategoryDto = await _categoryRepository.GetAllAsync(); - return new GetAllCategoryDto() { Categories = allCategoryDto}; + return new GetAllCategoryDto(allCategoryDto); } public async Task AddAsync(NewCategoryDto categoryDto) diff --git a/AnalysisData/AnalysisData/Services/TokenService/ValidateTokenService.cs b/AnalysisData/AnalysisData/Services/TokenService/ValidateTokenService.cs index b0d7571..5dae496 100644 --- a/AnalysisData/AnalysisData/Services/TokenService/ValidateTokenService.cs +++ b/AnalysisData/AnalysisData/Services/TokenService/ValidateTokenService.cs @@ -15,11 +15,9 @@ public ValidateTokenService(IPasswordResetTokensRepository resetTokensRepository public async Task ValidateResetToken(Guid userId, string resetPasswordToken) { - var resetToken = await _resetTokensRepository.GetToken(userId); + var resetToken = await _resetTokensRepository.GetToken(userId,resetPasswordToken); if (resetToken == null || resetToken.IsUsed) throw new TokenIsInvalidException(); - if (resetPasswordToken != resetToken.Token) - throw new TokenIsInvalidException(); if (resetToken.Expiration < DateTime.UtcNow) throw new TokenExpiredException();