Skip to content

Commit 9ec990f

Browse files
authored
Add null check on BackofficeUser access
This tag helper "sometimes" throws a null reference exception when accessing the BackofficeUser. The addition of the null check helps prevent this issue from occurring.
1 parent 308c97c commit 9ec990f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Our.Umbraco.TagHelpers/EditLinkTagHelper.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public override void Process(TagHelperContext context, TagHelperOutput output)
5252

5353
// Check if the user is logged in to the backoffice
5454
// and they have access to the content section
55-
if (_backofficeUserAccessor.BackofficeUser.IsAllowedToSeeEditLink())
55+
if (_backofficeUserAccessor?.BackofficeUser != null && _backofficeUserAccessor.BackofficeUser.IsAllowedToSeeEditLink())
5656
{
5757
// Try & get Umbraco Current Node int ID (Only do this if ContentId has NOT been set)
5858
if (_umbracoContextAccessor.TryGetUmbracoContext(out var umbracoContext) && ContentId == int.MinValue)
@@ -150,4 +150,4 @@ private static string GetOuterElementStyles(
150150
return outerStyles.ToString();
151151
}
152152
}
153-
}
153+
}

0 commit comments

Comments
 (0)