Skip to content

Commit

Permalink
Updated SameSiteMode in cookiepolicy, added setting of title for uplo…
Browse files Browse the repository at this point in the history
…aded images
  • Loading branch information
rubenriseld committed May 21, 2024
1 parent 1389591 commit 39b2ee3
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
2 changes: 2 additions & 0 deletions Gallery.API/DTOs/ImageDTO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
public record CreateImageDTO
{
public required string Uri { get; set; }
public string? Title { get; set; }

}
public record ReadImageDTO
{
Expand Down
4 changes: 2 additions & 2 deletions Gallery.API/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@
})
.AddCookie(IdentityConstants.ApplicationScheme, options =>
{
options.Cookie.SameSite = SameSiteMode.Strict;
options.Cookie.SameSite = SameSiteMode.None;
options.Cookie.HttpOnly = true;
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
options.ExpireTimeSpan = TimeSpan.FromDays(150);
Expand Down Expand Up @@ -111,7 +111,7 @@

app.UseCookiePolicy(new CookiePolicyOptions
{
MinimumSameSitePolicy = SameSiteMode.Strict,
MinimumSameSitePolicy = SameSiteMode.None,
HttpOnly = Microsoft.AspNetCore.CookiePolicy.HttpOnlyPolicy.Always,
Secure = CookieSecurePolicy.Always
});
Expand Down
2 changes: 1 addition & 1 deletion Gallery.API/Services/ImageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public async Task<List<ReadImageDTO>> UploadImages(
await client.UploadAsync(imageStream);
}

var imageEntity = _mapper.Map<Image>(new CreateImageDTO { Uri = absoluteUri });
var imageEntity = _mapper.Map<Image>(new CreateImageDTO { Uri = absoluteUri, Title = image.FileName});
await _imageRepository.Add(imageEntity);
await _imageRepository.SaveChanges();

Expand Down

0 comments on commit 39b2ee3

Please sign in to comment.