Ignore:
Timestamp:
06/23/26 15:20:39 (13 days ago)
Author:
kikisrbinoska <srbinoskakristina07@…>
Branches:
main
Children:
0b502c2
Parents:
d300631
Message:

Fixes for authentication and auhtorization\

Location:
ChapterX.Application/Comment/Commands
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • ChapterX.Application/Comment/Commands/AddRequest.cs

    rd300631 rb373fea  
    11using MediatR;
     2using System.ComponentModel.DataAnnotations;
    23
    34namespace ChapterX.Application.Comment.Commands
    45{
    5     public record AddRequest(string Content, int UserId, int StoryId) : IRequest<AddResponse>;
     6    public record AddRequest(
     7        [Required][MaxLength(2000)] string Content,
     8        int UserId,
     9        int StoryId
     10    ) : IRequest<AddResponse>;
    611}
  • ChapterX.Application/Comment/Commands/DeleteHandler.cs

    rd300631 rb373fea  
    2222                return new DeleteResponse(false);
    2323
     24            if (comment.UserId != request.CallerId)
     25                throw new UnauthorizedAccessException("You do not own this comment.");
     26
    2427            await _commentRepository.DeleteAsync(comment, cancellationToken);
    2528
  • ChapterX.Application/Comment/Commands/DeleteRequest.cs

    rd300631 rb373fea  
    33namespace ChapterX.Application.Comment.Commands
    44{
    5     public record DeleteRequest(int Id) : IRequest<DeleteResponse>;
     5    public record DeleteRequest(int Id, int CallerId) : IRequest<DeleteResponse>;
    66}
  • ChapterX.Application/Comment/Commands/UpdateHandler.cs

    rd300631 rb373fea  
    2222                return new UpdateResponse(false);
    2323
     24            if (comment.UserId != request.CallerId)
     25                throw new UnauthorizedAccessException("You do not own this comment.");
     26
    2427            comment.Content = request.Content;
    2528            comment.UpdatedAt = DateTime.UtcNow;
  • ChapterX.Application/Comment/Commands/UpdateRequest.cs

    rd300631 rb373fea  
    33namespace ChapterX.Application.Comment.Commands
    44{
    5     public record UpdateRequest(int Id, string Content) : IRequest<UpdateResponse>;
     5    public record UpdateRequest(int Id, string Content, int CallerId = 0) : IRequest<UpdateResponse>;
    66}
Note: See TracChangeset for help on using the changeset viewer.