From 9a884d78b6442b03f50a5c9820c39823828c008a Mon Sep 17 00:00:00 2001 From: Dominic Villemure Date: Wed, 10 Jul 2024 01:56:06 -0400 Subject: [PATCH] Dont check contentType before we know if the url is provided --- src/Application/Users/Commands/UploadBannerPicture.cs | 4 ++-- src/Application/Users/Commands/UploadProfilePicture.cs | 4 ++-- src/Application/Users/Commands/UploadWebsiteIcon.cs | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Application/Users/Commands/UploadBannerPicture.cs b/src/Application/Users/Commands/UploadBannerPicture.cs index 3bab003..be7590f 100644 --- a/src/Application/Users/Commands/UploadBannerPicture.cs +++ b/src/Application/Users/Commands/UploadBannerPicture.cs @@ -18,8 +18,6 @@ public class UploadBannerPictureCommandHandler(IHttpContextAccessor contextAcces { public async Task Handle(UploadBannerPictureCommand request, CancellationToken cancellationToken) { - var contentType = contextAccessor.EnsureContentType(); - // If an url to the picture is provided, use it right away and don't upload anything. if (!string.IsNullOrEmpty(request.BannerPictureUrl)) { @@ -27,6 +25,8 @@ public class UploadBannerPictureCommandHandler(IHttpContextAccessor contextAcces return Results.Ok(request.BannerPictureUrl); } + var contentType = contextAccessor.EnsureContentType(); + var identityUser = await identityService.GetCurrentUserAsync(); var currentUserId = new Guid(identityUser?.Id ?? "").ToString(); diff --git a/src/Application/Users/Commands/UploadProfilePicture.cs b/src/Application/Users/Commands/UploadProfilePicture.cs index 0dbb394..2e017d2 100644 --- a/src/Application/Users/Commands/UploadProfilePicture.cs +++ b/src/Application/Users/Commands/UploadProfilePicture.cs @@ -18,8 +18,6 @@ public class UploadProfilePictureCommandHandler(IHttpContextAccessor contextAcce { public async Task Handle(UploadProfilePictureCommand request, CancellationToken cancellationToken) { - var contentType = contextAccessor.EnsureContentType(); - // If an url to the picture is provided, use it right away and don't upload anything. if (!string.IsNullOrEmpty(request.ProfilePictureUrl)) { @@ -27,6 +25,8 @@ public class UploadProfilePictureCommandHandler(IHttpContextAccessor contextAcce return Results.Ok(request.ProfilePictureUrl); } + var contentType = contextAccessor.EnsureContentType(); + var identityUser = await identityService.GetCurrentUserAsync(); var currentUserId = new Guid(identityUser?.Id ?? "").ToString(); diff --git a/src/Application/Users/Commands/UploadWebsiteIcon.cs b/src/Application/Users/Commands/UploadWebsiteIcon.cs index 29158b2..eaa8cd6 100644 --- a/src/Application/Users/Commands/UploadWebsiteIcon.cs +++ b/src/Application/Users/Commands/UploadWebsiteIcon.cs @@ -19,8 +19,6 @@ public class UploadWebsiteIconCommandHandler(IHttpContextAccessor contextAccesso { public async Task Handle(UploadWebsiteIconCommand request, CancellationToken cancellationToken) { - var contentType = contextAccessor.EnsureContentType(); - // If an url to the picture is provided, use it right away and don't upload anything. if (!string.IsNullOrEmpty(request.WebsitePictureUrl)) { @@ -28,6 +26,8 @@ public class UploadWebsiteIconCommandHandler(IHttpContextAccessor contextAccesso return Results.Ok(request.WebsitePictureUrl); } + var contentType = contextAccessor.EnsureContentType(); + var identityUser = await identityService.GetCurrentUserAsync(); var currentUserId = new Guid(identityUser?.Id ?? "").ToString();