From dc999fd7cc56d0a861a8f9619abb24d37a3382b0 Mon Sep 17 00:00:00 2001 From: john Date: Wed, 21 May 2025 13:52:12 +0200 Subject: [PATCH] fix loading public posts --- Femto.Api/Controllers/Posts/PostsController.cs | 2 +- Femto.Api/CurrentUserContext.cs | 2 +- Femto.Common/ICurrentUserContext.cs | 4 +--- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/Femto.Api/Controllers/Posts/PostsController.cs b/Femto.Api/Controllers/Posts/PostsController.cs index ce2d75f..2b1e830 100644 --- a/Femto.Api/Controllers/Posts/PostsController.cs +++ b/Femto.Api/Controllers/Posts/PostsController.cs @@ -76,6 +76,6 @@ public class PostsController(IBlogModule blogModule, ICurrentUserContext current [Authorize] public async Task DeletePost(Guid postId, CancellationToken cancellationToken) { - await blogModule.Command(new DeletePostCommand(postId, currentUserContext.CurrentUser.Id), cancellationToken); + await blogModule.Command(new DeletePostCommand(postId, currentUserContext.CurrentUser!.Id), cancellationToken); } } diff --git a/Femto.Api/CurrentUserContext.cs b/Femto.Api/CurrentUserContext.cs index 01d0d5c..1164eb0 100644 --- a/Femto.Api/CurrentUserContext.cs +++ b/Femto.Api/CurrentUserContext.cs @@ -6,7 +6,7 @@ internal class CurrentUserContext : ICurrentUserContext { private CurrentUser? _currentUser; - public CurrentUser? tryGetUserCurrentUser() => this._currentUser; + public CurrentUser? TryGetUserCurrentUser() => this._currentUser; public bool HasUser => this._currentUser is not null; diff --git a/Femto.Common/ICurrentUserContext.cs b/Femto.Common/ICurrentUserContext.cs index 0cb0207..f09e417 100644 --- a/Femto.Common/ICurrentUserContext.cs +++ b/Femto.Common/ICurrentUserContext.cs @@ -2,10 +2,8 @@ namespace Femto.Common; public interface ICurrentUserContext { - CurrentUser? tryGetUserCurrentUser(); - bool HasUser { get; } - CurrentUser CurrentUser { get; } + CurrentUser? CurrentUser { get; } } public record CurrentUser(Guid Id, string Username, string SessionId);