From 83baba696cd4b6b485622d8d1162c95f6793868b Mon Sep 17 00:00:00 2001
From: Nikolaj Geisle <70372949+Zeegaan@users.noreply.github.com>
Date: Thu, 10 Feb 2022 10:32:45 +0100
Subject: [PATCH] Fixed build errors after turning nullability errors off
---
src/Umbraco.Core/AttemptOfTResult.cs | 10 ++++++-
.../Media/Exif/ExifFileTypeDescriptor.cs | 2 +-
src/Umbraco.Core/Media/Exif/MathEx.cs | 2 +-
.../Persistence/IReadRepository.cs | 4 +--
.../Repositories/IUserRepository.cs | 4 +--
.../Security/IBackofficeSecurity.cs | 2 +-
src/Umbraco.Core/Umbraco.Core.csproj | 2 +-
.../Examine/ContentValueSetValidator.cs | 2 +-
.../Enrichers/HttpRequestIdEnricher.cs | 2 +-
.../Persistence/Dtos/UserLoginDto.cs | 2 +-
.../Factories/PropertyGroupFactory.cs | 2 +-
.../Repositories/Implement/UserRepository.cs | 4 +--
.../ConfigurationEditorOfTConfiguration.cs | 2 +-
.../MultipleTextStringConfigurationEditor.cs | 4 +--
.../Routing/NotFoundHandlerHelper.cs | 2 +-
.../Services/IdKeyMap.cs | 2 +-
.../Services/Implement/DataTypeService.cs | 2 +-
.../Implement/LocalizedTextService.cs | 2 +-
.../Implement/PropertyValidationService.cs | 4 +--
.../Controllers/AuthenticationController.cs | 2 +-
.../Controllers/BackOfficeServerVariables.cs | 1 -
.../Controllers/ContentController.cs | 28 +++++++++----------
.../Controllers/ContentTypeController.cs | 5 +++-
.../Controllers/CurrentUserController.cs | 6 ++--
.../Controllers/LogController.cs | 2 +-
.../Controllers/MediaController.cs | 12 ++++----
.../Controllers/PackageController.cs | 6 ++--
...erSwapControllerActionSelectorAttribute.cs | 2 +-
.../Controllers/SectionController.cs | 2 +-
.../Controllers/UsersController.cs | 2 +-
.../CheckIfUserTicketDataIsStaleAttribute.cs | 8 +++++-
.../Filters/ContentModelValidator.cs | 2 +-
.../HealthChecks/HealthCheckController.cs | 2 +-
.../ConfigureBackOfficeCookieOptions.cs | 2 +-
.../Trees/ContentTreeController.cs | 2 +-
.../Middleware/UmbracoRequestMiddleware.cs | 4 +--
.../Security/BackofficeSecurity.cs | 12 +++++---
.../Security/MemberManager.cs | 2 +-
.../Routing/PublicAccessRequestHandler.cs | 2 +-
39 files changed, 91 insertions(+), 69 deletions(-)
diff --git a/src/Umbraco.Core/AttemptOfTResult.cs b/src/Umbraco.Core/AttemptOfTResult.cs
index 20ae500a7e..97950a60c5 100644
--- a/src/Umbraco.Core/AttemptOfTResult.cs
+++ b/src/Umbraco.Core/AttemptOfTResult.cs
@@ -35,7 +35,15 @@ namespace Umbraco.Cms.Core
///
/// Gets the attempt result, if successful, else a default value.
///
- public TResult? ResultOr(TResult? value) => Success ? Result : value;
+ public TResult ResultOr(TResult value)
+ {
+ if (Success && Result is not null)
+ {
+ return Result;
+ }
+
+ return value;
+ }
// optimize, use a singleton failed attempt
private static readonly Attempt Failed = new Attempt(false, default(TResult), null);
diff --git a/src/Umbraco.Core/Media/Exif/ExifFileTypeDescriptor.cs b/src/Umbraco.Core/Media/Exif/ExifFileTypeDescriptor.cs
index a4c001935b..92b0a16dc3 100644
--- a/src/Umbraco.Core/Media/Exif/ExifFileTypeDescriptor.cs
+++ b/src/Umbraco.Core/Media/Exif/ExifFileTypeDescriptor.cs
@@ -27,7 +27,7 @@ namespace Umbraco.Cms.Core.Media.Exif
///
/// An that can provide metadata for the type.
///
- public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
+ public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object? instance)
{
return new ExifFileTypeDescriptor(base.GetTypeDescriptor(objectType, instance), instance);
}
diff --git a/src/Umbraco.Core/Media/Exif/MathEx.cs b/src/Umbraco.Core/Media/Exif/MathEx.cs
index 5262aa18a8..6c73f44df0 100644
--- a/src/Umbraco.Core/Media/Exif/MathEx.cs
+++ b/src/Umbraco.Core/Media/Exif/MathEx.cs
@@ -472,7 +472,7 @@ namespace Umbraco.Cms.Core.Media.Exif
/// Another object to compare to.
/// true if obj and this instance are the same type and represent
/// the same value; otherwise, false.
- public override bool Equals(object obj)
+ public override bool Equals(object? obj)
{
if (obj == null)
return false;
diff --git a/src/Umbraco.Core/Persistence/IReadRepository.cs b/src/Umbraco.Core/Persistence/IReadRepository.cs
index ea5d24f774..3e495f7e36 100644
--- a/src/Umbraco.Core/Persistence/IReadRepository.cs
+++ b/src/Umbraco.Core/Persistence/IReadRepository.cs
@@ -10,12 +10,12 @@ namespace Umbraco.Cms.Core.Persistence
///
/// Gets an entity.
///
- TEntity Get(TId id);
+ TEntity? Get(TId? id);
///
/// Gets entities.
///
- IEnumerable GetMany(params TId[] ids);
+ IEnumerable GetMany(params TId?[] ids);
///
/// Gets a value indicating whether an entity exists.
diff --git a/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs b/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs
index 2d77efa5ee..188c2dc067 100644
--- a/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs
+++ b/src/Umbraco.Core/Persistence/Repositories/IUserRepository.cs
@@ -95,13 +95,13 @@ namespace Umbraco.Cms.Core.Persistence.Repositories
///
/// A non cached instance
///
- IUser Get(int id, bool includeSecurityData);
+ IUser Get(int? id, bool includeSecurityData);
IProfile GetProfile(string username);
IProfile GetProfile(int id);
IDictionary GetUserStates();
- Guid CreateLoginSession(int userId, string requestingIpAddress, bool cleanStaleSessions = true);
+ Guid CreateLoginSession(int? userId, string requestingIpAddress, bool cleanStaleSessions = true);
bool ValidateLoginSession(int userId, Guid sessionId);
int ClearLoginSessions(int userId);
int ClearLoginSessions(TimeSpan timespan);
diff --git a/src/Umbraco.Core/Security/IBackofficeSecurity.cs b/src/Umbraco.Core/Security/IBackofficeSecurity.cs
index b4eabd6744..3bfcd8e1ee 100644
--- a/src/Umbraco.Core/Security/IBackofficeSecurity.cs
+++ b/src/Umbraco.Core/Security/IBackofficeSecurity.cs
@@ -21,7 +21,7 @@ namespace Umbraco.Cms.Core.Security
/// The current user's Id that has been authenticated for the request.
/// If authentication hasn't taken place this will be unsuccessful.
// TODO: This should just be an extension method on ClaimsIdentity
- Attempt GetUserId();
+ Attempt GetUserId();
///
/// Checks if the specified user as access to the app
diff --git a/src/Umbraco.Core/Umbraco.Core.csproj b/src/Umbraco.Core/Umbraco.Core.csproj
index 62f0f8652e..2252aa36f2 100644
--- a/src/Umbraco.Core/Umbraco.Core.csproj
+++ b/src/Umbraco.Core/Umbraco.Core.csproj
@@ -9,7 +9,7 @@
Contains the core assembly needed to run Umbraco Cms. This package only contains the assembly, and can be used for package development. Use the template in the Umbraco.Templates package to setup Umbraco
Umbraco CMS
enable
- Nullable
+
diff --git a/src/Umbraco.Infrastructure/Examine/ContentValueSetValidator.cs b/src/Umbraco.Infrastructure/Examine/ContentValueSetValidator.cs
index ddd97adb1a..e6039e2d79 100644
--- a/src/Umbraco.Infrastructure/Examine/ContentValueSetValidator.cs
+++ b/src/Umbraco.Infrastructure/Examine/ContentValueSetValidator.cs
@@ -64,7 +64,7 @@ namespace Umbraco.Cms.Infrastructure.Examine
// explicit scope since we may be in a background thread
using (_scopeProvider.CreateScope(autoComplete: true))
{
- if (_publicAccessService.IsProtected(path))
+ if (_publicAccessService.IsProtected(path).Success)
{
return false;
}
diff --git a/src/Umbraco.Infrastructure/Logging/Serilog/Enrichers/HttpRequestIdEnricher.cs b/src/Umbraco.Infrastructure/Logging/Serilog/Enrichers/HttpRequestIdEnricher.cs
index 4a794c06ec..3d9182cb96 100644
--- a/src/Umbraco.Infrastructure/Logging/Serilog/Enrichers/HttpRequestIdEnricher.cs
+++ b/src/Umbraco.Infrastructure/Logging/Serilog/Enrichers/HttpRequestIdEnricher.cs
@@ -34,7 +34,7 @@ namespace Umbraco.Cms.Core.Logging.Serilog.Enrichers
{
if (logEvent == null) throw new ArgumentNullException(nameof(logEvent));
- Guid requestId;
+ Guid? requestId;
if (!LogHttpRequest.TryGetCurrentHttpRequestId(out requestId, _requestCache))
return;
diff --git a/src/Umbraco.Infrastructure/Persistence/Dtos/UserLoginDto.cs b/src/Umbraco.Infrastructure/Persistence/Dtos/UserLoginDto.cs
index c0869b967b..6508afcec0 100644
--- a/src/Umbraco.Infrastructure/Persistence/Dtos/UserLoginDto.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Dtos/UserLoginDto.cs
@@ -17,7 +17,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Dtos
[Column("userId")]
[ForeignKey(typeof(UserDto), Name = "FK_" + TableName + "_umbracoUser_id")]
- public int UserId { get; set; }
+ public int? UserId { get; set; }
///
/// Tracks when the session is created
diff --git a/src/Umbraco.Infrastructure/Persistence/Factories/PropertyGroupFactory.cs b/src/Umbraco.Infrastructure/Persistence/Factories/PropertyGroupFactory.cs
index 10b6aadea3..2e73ff037c 100644
--- a/src/Umbraco.Infrastructure/Persistence/Factories/PropertyGroupFactory.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Factories/PropertyGroupFactory.cs
@@ -131,7 +131,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Factories
ContentTypeId = contentTypeId,
DataTypeId = propertyType.DataTypeId,
Description = propertyType.Description,
- Mandatory = propertyType.Mandatory,
+ Mandatory = propertyType.Mandatory ?? false,
MandatoryMessage = propertyType.MandatoryMessage,
Name = propertyType.Name,
SortOrder = propertyType.SortOrder,
diff --git a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs
index b94daf5d83..90ab0fa88c 100644
--- a/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs
+++ b/src/Umbraco.Infrastructure/Persistence/Repositories/Implement/UserRepository.cs
@@ -157,7 +157,7 @@ namespace Umbraco.Cms.Infrastructure.Persistence.Repositories.Implement
///
/// A non cached instance
///
- public IUser Get(int id, bool includeSecurityData)
+ public IUser Get(int? id, bool includeSecurityData)
{
return GetWith(sql => sql.Where(x => x.Id == id), includeSecurityData);
}
@@ -194,7 +194,7 @@ SELECT 4 AS [Key], COUNT(id) AS [Value] FROM umbracoUser WHERE userDisabled = 0
return result.ToDictionary(x => (UserState)x.Key, x => x.Value);
}
- public Guid CreateLoginSession(int userId, string requestingIpAddress, bool cleanStaleSessions = true)
+ public Guid CreateLoginSession(int? userId, string requestingIpAddress, bool cleanStaleSessions = true)
{
var now = DateTime.UtcNow;
var dto = new UserLoginDto
diff --git a/src/Umbraco.Infrastructure/PropertyEditors/ConfigurationEditorOfTConfiguration.cs b/src/Umbraco.Infrastructure/PropertyEditors/ConfigurationEditorOfTConfiguration.cs
index 53a3c63510..31fd95304c 100644
--- a/src/Umbraco.Infrastructure/PropertyEditors/ConfigurationEditorOfTConfiguration.cs
+++ b/src/Umbraco.Infrastructure/PropertyEditors/ConfigurationEditorOfTConfiguration.cs
@@ -159,7 +159,7 @@ namespace Umbraco.Cms.Core.PropertyEditors
{
//if it's a boolean property type but a string is found, try to do a conversion
var converted = sBool.TryConvertTo();
- if (converted)
+ if (converted.Success)
o[field.PropertyName] = converted.Result;
}
else
diff --git a/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringConfigurationEditor.cs b/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringConfigurationEditor.cs
index 1ee06ecfbc..826016fd20 100644
--- a/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringConfigurationEditor.cs
+++ b/src/Umbraco.Infrastructure/PropertyEditors/MultipleTextStringConfigurationEditor.cs
@@ -45,8 +45,8 @@ namespace Umbraco.Cms.Core.PropertyEditors
return new MultipleTextStringConfiguration
{
- Minimum = min ? min.Result : 0,
- Maximum = max ? max.Result : 0
+ Minimum = min.Success ? min.Result : 0,
+ Maximum = max.Success ? max.Result : 0
};
}
diff --git a/src/Umbraco.Infrastructure/Routing/NotFoundHandlerHelper.cs b/src/Umbraco.Infrastructure/Routing/NotFoundHandlerHelper.cs
index a94f73116a..1aec33e10f 100644
--- a/src/Umbraco.Infrastructure/Routing/NotFoundHandlerHelper.cs
+++ b/src/Umbraco.Infrastructure/Routing/NotFoundHandlerHelper.cs
@@ -63,7 +63,7 @@ namespace Umbraco.Cms.Core.Routing
// but until then we need to look it up in the db. For now we've implemented a cached service for
// converting Int -> Guid and vice versa.
Attempt found = entityService.GetId(errorPage.ContentKey, UmbracoObjectTypes.Document);
- if (found)
+ if (found.Success)
{
return found.Result;
}
diff --git a/src/Umbraco.Infrastructure/Services/IdKeyMap.cs b/src/Umbraco.Infrastructure/Services/IdKeyMap.cs
index 49747534c6..2acc57b372 100644
--- a/src/Umbraco.Infrastructure/Services/IdKeyMap.cs
+++ b/src/Umbraco.Infrastructure/Services/IdKeyMap.cs
@@ -215,7 +215,7 @@ namespace Umbraco.Cms.Core.Services
public Attempt GetUdiForId(int id, UmbracoObjectTypes umbracoObjectType)
{
var keyAttempt = GetKeyForId(id, umbracoObjectType);
- return keyAttempt
+ return keyAttempt.Success
? Attempt.Succeed(new GuidUdi(UdiEntityTypeHelper.FromUmbracoObjectType(umbracoObjectType), keyAttempt.Result))
: Attempt.Fail();
}
diff --git a/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs b/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs
index b5173e800e..a37793207d 100644
--- a/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs
+++ b/src/Umbraco.Infrastructure/Services/Implement/DataTypeService.cs
@@ -127,7 +127,7 @@ namespace Umbraco.Cms.Core.Services.Implement
.Select(x =>
{
var asInt = x.TryConvertTo();
- return asInt ? asInt.Result : int.MinValue;
+ return asInt.Success ? asInt.Result : int.MinValue;
})
.Where(x => x != int.MinValue && x != dataType.Id)
.ToArray();
diff --git a/src/Umbraco.Infrastructure/Services/Implement/LocalizedTextService.cs b/src/Umbraco.Infrastructure/Services/Implement/LocalizedTextService.cs
index d09abb02b0..535dacb3b2 100644
--- a/src/Umbraco.Infrastructure/Services/Implement/LocalizedTextService.cs
+++ b/src/Umbraco.Infrastructure/Services/Implement/LocalizedTextService.cs
@@ -369,7 +369,7 @@ namespace Umbraco.Cms.Core.Services.Implement
if (currentCulture.Name.Length > 2) return currentCulture;
var attempt = _fileSources.Value.TryConvert2LetterCultureTo4Letter(currentCulture.TwoLetterISOLanguageName);
- return attempt ? attempt.Result : currentCulture;
+ return attempt.Success ? attempt.Result : currentCulture;
}
private string GetFromDictionarySource(CultureInfo culture, string area, string key,
diff --git a/src/Umbraco.Infrastructure/Services/Implement/PropertyValidationService.cs b/src/Umbraco.Infrastructure/Services/Implement/PropertyValidationService.cs
index 70580153de..030b2ae832 100644
--- a/src/Umbraco.Infrastructure/Services/Implement/PropertyValidationService.cs
+++ b/src/Umbraco.Infrastructure/Services/Implement/PropertyValidationService.cs
@@ -40,7 +40,7 @@ namespace Umbraco.Cms.Core.Services.Implement
var editor = _propertyEditors[propertyType.PropertyEditorAlias];
if (editor == null) throw new InvalidOperationException("No property editor found by alias " + propertyType.PropertyEditorAlias);
- return ValidatePropertyValue(editor, dataType, postedValue, propertyType.Mandatory, propertyType.ValidationRegExp, propertyType.MandatoryMessage, propertyType.ValidationRegExpMessage);
+ return ValidatePropertyValue(editor, dataType, postedValue, propertyType.Mandatory ?? false, propertyType.ValidationRegExp, propertyType.MandatoryMessage, propertyType.ValidationRegExpMessage);
}
///
@@ -188,7 +188,7 @@ namespace Umbraco.Cms.Core.Services.Implement
}
var configuration = _dataTypeService.GetDataType(propertyType.DataTypeId).Configuration;
var valueEditor = editor.GetValueEditor(configuration);
- return !valueEditor.Validate(value, propertyType.Mandatory, propertyType.ValidationRegExp).Any();
+ return !valueEditor.Validate(value, propertyType.Mandatory ?? false, propertyType.ValidationRegExp).Any();
}
}
}
diff --git a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs
index cc8ff205b7..75791fb283 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/AuthenticationController.cs
@@ -120,7 +120,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
[Authorize(Policy = AuthorizationPolicies.BackOfficeAccess)] // Needed to enforce the principle set on the request, if one exists.
public IDictionary GetPasswordConfig(int userId)
{
- Attempt currentUserId = _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId();
+ Attempt currentUserId = _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId();
return _passwordConfiguration.GetConfiguration(
currentUserId.Success
? currentUserId.Result != userId
diff --git a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
index 2e81a0905b..2f67da6caf 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/BackOfficeServerVariables.cs
@@ -25,7 +25,6 @@ using Umbraco.Cms.Web.BackOffice.Security;
using Umbraco.Cms.Web.BackOffice.Trees;
using Umbraco.Cms.Web.Common.Attributes;
using Umbraco.Extensions;
-using Constants = Umbraco.Cms.Core.Constants;
namespace Umbraco.Cms.Web.BackOffice.Controllers
{
diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs
index 7ecb8d3c0c..25abbf1fab 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/ContentController.cs
@@ -419,7 +419,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
private ContentItemDisplay GetEmptyInner(IContentType contentType, int parentId)
{
- var emptyContent = _contentService.Create("", parentId, contentType.Alias, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ var emptyContent = _contentService.Create("", parentId, contentType.Alias, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
var mapped = MapToDisplay(emptyContent);
return CleanContentItemDisplay(mapped);
@@ -451,7 +451,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
var result = new List();
var backOfficeSecurity = _backofficeSecurityAccessor.BackOfficeSecurity;
- var userId = backOfficeSecurity.GetUserId().ResultOr(0);
+ var userId = backOfficeSecurity.GetUserId().Result ?? 0;
var currentUser = backOfficeSecurity.CurrentUser;
// We know that if the ID is less than 0 the parent is null.
// Since this is called with parent ID it's safe to assume that the parent is the same for all the content types.
@@ -670,9 +670,9 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
return ValidationProblem(ModelState);
}
- var blueprint = _contentService.CreateContentFromBlueprint(content, name, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ var blueprint = _contentService.CreateContentFromBlueprint(content, name, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
- _contentService.SaveBlueprint(blueprint, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ _contentService.SaveBlueprint(blueprint, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
var notificationModel = new SimpleNotificationModel();
notificationModel.AddSuccessNotification(
@@ -1649,7 +1649,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
return HandleContentNotFound(id);
}
- var publishResult = _contentService.SaveAndPublish(foundContent, userId: _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ var publishResult = _contentService.SaveAndPublish(foundContent, userId: _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
if (publishResult.Success == false)
{
var notificationModel = new SimpleNotificationModel();
@@ -1701,7 +1701,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//if the current item is in the recycle bin
if (foundContent.Trashed == false)
{
- var moveResult = _contentService.MoveToRecycleBin(foundContent, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ var moveResult = _contentService.MoveToRecycleBin(foundContent, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
if (moveResult.Success == false)
{
return ValidationProblem();
@@ -1709,7 +1709,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
}
else
{
- var deleteResult = _contentService.Delete(foundContent, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ var deleteResult = _contentService.Delete(foundContent, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
if (deleteResult.Success == false)
{
return ValidationProblem();
@@ -1731,7 +1731,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
[Authorize(Policy = AuthorizationPolicies.ContentPermissionEmptyRecycleBin)]
public IActionResult EmptyRecycleBin()
{
- _contentService.EmptyRecycleBin(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
+ _contentService.EmptyRecycleBin(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? -1);
return Ok(_localizedTextService.Localize("defaultdialogs", "recycleBinIsEmpty"));
}
@@ -1804,7 +1804,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
}
var toMove = toMoveResult.Value;
- _contentService.Move(toMove, move.ParentId, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ _contentService.Move(toMove, move.ParentId, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
return Content(toMove.Path, MediaTypeNames.Text.Plain, Encoding.UTF8);
}
@@ -1830,7 +1830,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
return toCopyResult.Result;
}
var toCopy = toCopyResult.Value;
- var c = _contentService.Copy(toCopy, copy.ParentId, copy.RelateToOriginal, copy.Recursive, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ var c = _contentService.Copy(toCopy, copy.ParentId, copy.RelateToOriginal, copy.Recursive, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
return Content(c.Path, MediaTypeNames.Text.Plain, Encoding.UTF8);
}
@@ -1862,7 +1862,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
if (model.Cultures.Length == 0 || model.Cultures.Length == languageCount)
{
//this means that the entire content item will be unpublished
- var unpublishResult = _contentService.Unpublish(foundContent, userId: _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ var unpublishResult = _contentService.Unpublish(foundContent, userId: _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
var content = MapToDisplayWithSchedule(foundContent);
@@ -1885,7 +1885,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
var results = new Dictionary();
foreach (var c in model.Cultures)
{
- var result = _contentService.Unpublish(foundContent, culture: c, userId: _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ var result = _contentService.Unpublish(foundContent, culture: c, userId: _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
results[c] = result;
if (result.Result == PublishResultType.SuccessUnpublishMandatoryCulture)
{
@@ -2544,7 +2544,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
return NotFound();
}
- _contentVersionService.SetPreventCleanup(versionId, preventCleanup, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ _contentVersionService.SetPreventCleanup(versionId, preventCleanup, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
return NoContent();
}
@@ -2609,7 +2609,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
[HttpPost]
public IActionResult PostRollbackContent(int contentId, int versionId, string culture = "*")
{
- var rollbackResult = _contentService.Rollback(contentId, versionId, culture, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ var rollbackResult = _contentService.Rollback(contentId, versionId, culture, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
if (rollbackResult.Success)
return Ok();
diff --git a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs
index 8282969013..9164588d7d 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/ContentTypeController.cs
@@ -562,7 +562,10 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
var userId = _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0);
var element = XElement.Parse(xd.InnerXml);
- _packageDataInstallation.ImportDocumentType(element, userId);
+ if (userId is not null)
+ {
+ _packageDataInstallation.ImportDocumentType(element, userId.Value);
+ }
// Try to clean up the temporary file.
try
diff --git a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs
index 5569fdcfc2..d2ba59cc65 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/CurrentUserController.cs
@@ -244,8 +244,10 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
[AppendUserModifiedHeader]
public IActionResult PostSetAvatar(IList file)
{
+ var userId = _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId();
+ var result = userId.ResultOr(0);
//borrow the logic from the user controller
- return UsersController.PostSetAvatarInternal(file, _userService, _appCaches.RuntimeCache, _mediaFileManager, _shortStringHelper, _contentSettings, _hostingEnvironment, _imageUrlGenerator, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ return UsersController.PostSetAvatarInternal(file, _userService, _appCaches.RuntimeCache, _mediaFileManager, _shortStringHelper, _contentSettings, _hostingEnvironment, _imageUrlGenerator, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
}
///
@@ -285,7 +287,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
[ValidateAngularAntiForgeryToken]
public async Task> GetCurrentUserLinkedLogins()
{
- var identityUser = await _backOfficeUserManager.FindByIdAsync(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0).ToString(CultureInfo.InvariantCulture));
+ var identityUser = await _backOfficeUserManager.FindByIdAsync(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0)?.ToString(CultureInfo.InvariantCulture));
// deduplicate in case there are duplicates (there shouldn't be now since we have a unique constraint on the external logins
// but there didn't used to be)
diff --git a/src/Umbraco.Web.BackOffice/Controllers/LogController.cs b/src/Umbraco.Web.BackOffice/Controllers/LogController.cs
index 3c3eaa4eff..5134c99792 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/LogController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/LogController.cs
@@ -91,7 +91,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
long totalRecords;
var dateQuery = sinceDate.HasValue ? _sqlContext.Query().Where(x => x.CreateDate >= sinceDate) : null;
- var userId = _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0);
+ var userId = _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0;
var result = _auditService.GetPagedItemsByUser(userId, pageNumber - 1, pageSize, out totalRecords, orderDirection, customFilter:dateQuery);
var mapped = _umbracoMapper.MapEnumerable(result);
return new PagedResult(totalRecords, pageNumber, pageSize)
diff --git a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs
index a6485768f1..c3d947ac70 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/MediaController.cs
@@ -135,7 +135,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
return NotFound();
}
- var emptyContent = _mediaService.CreateMedia("", parentId, contentType.Alias, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
+ var emptyContent = _mediaService.CreateMedia("", parentId, contentType.Alias, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? -1);
var mapped = _umbracoMapper.Map(emptyContent);
//remove the listview app if it exists
@@ -452,7 +452,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
//if the current item is in the recycle bin
if (foundMedia.Trashed == false)
{
- var moveResult = _mediaService.MoveToRecycleBin(foundMedia, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
+ var moveResult = _mediaService.MoveToRecycleBin(foundMedia, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? -1);
if (moveResult == false)
{
return ValidationProblem();
@@ -460,7 +460,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
}
else
{
- var deleteResult = _mediaService.Delete(foundMedia, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
+ var deleteResult = _mediaService.Delete(foundMedia, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? -1);
if (deleteResult == false)
{
return ValidationProblem();
@@ -495,7 +495,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
var destinationParentID = move.ParentId;
var sourceParentID = toMove.ParentId;
- var moveResult = _mediaService.Move(toMove, move.ParentId, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
+ var moveResult = _mediaService.Move(toMove, move.ParentId, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? -1);
if (sourceParentID == destinationParentID)
{
@@ -568,7 +568,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
}
//save the item
- var saveStatus = _mediaService.Save(contentItem.PersistedContent, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
+ var saveStatus = _mediaService.Save(contentItem.PersistedContent, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? -1);
//return the updated model
var display = _umbracoMapper.Map(contentItem.PersistedContent);
@@ -617,7 +617,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
[HttpPost]
public IActionResult EmptyRecycleBin()
{
- _mediaService.EmptyRecycleBin(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(Constants.Security.SuperUserId));
+ _mediaService.EmptyRecycleBin(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? -1);
return Ok(_localizedTextService.Localize("defaultdialogs", "recycleBinIsEmpty"));
}
diff --git a/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs b/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs
index 813682c70e..43518927ed 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/PackageController.cs
@@ -93,7 +93,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
[HttpDelete]
public IActionResult DeleteCreatedPackage(int packageId)
{
- _packagingService.DeleteCreatedPackage(packageId, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ _packagingService.DeleteCreatedPackage(packageId, _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? -1);
return Ok();
}
@@ -112,11 +112,11 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
return ValidationErrorResult.CreateNotificationValidationErrorResult(
$"Package migration failed on package {packageName} with error: {ex.Message}. Check log for full details.");
- }
+ }
}
[HttpGet]
- public IActionResult DownloadCreatedPackage(int id)
+ public IActionResult DownloadCreatedPackage(int id)
{
var package = _packagingService.GetCreatedPackageById(id);
if (package == null)
diff --git a/src/Umbraco.Web.BackOffice/Controllers/ParameterSwapControllerActionSelectorAttribute.cs b/src/Umbraco.Web.BackOffice/Controllers/ParameterSwapControllerActionSelectorAttribute.cs
index 3fafd2c1e4..c1ef5b153e 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/ParameterSwapControllerActionSelectorAttribute.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/ParameterSwapControllerActionSelectorAttribute.cs
@@ -180,7 +180,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
var enumType = paramType.GetEnumeratedType();
var converted = requestParam.TryConvertTo(enumType ?? paramType);
- if (converted)
+ if (converted.Success)
{
foundCandidate = MatchByType(paramType, context);
if (foundCandidate.HasValue)
diff --git a/src/Umbraco.Web.BackOffice/Controllers/SectionController.cs b/src/Umbraco.Web.BackOffice/Controllers/SectionController.cs
index dfd1c8c973..3432d4ae12 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/SectionController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/SectionController.cs
@@ -53,7 +53,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
public async Task>> GetSections()
{
- var sections = _sectionService.GetAllowedSections(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().ResultOr(0));
+ var sections = _sectionService.GetAllowedSections(_backofficeSecurityAccessor.BackOfficeSecurity.GetUserId().Result ?? 0);
var sectionModels = sections.Select(_umbracoMapper.Map).ToArray();
diff --git a/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs b/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs
index db23e3b04c..012f910596 100644
--- a/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs
+++ b/src/Umbraco.Web.BackOffice/Controllers/UsersController.cs
@@ -716,7 +716,7 @@ namespace Umbraco.Cms.Web.BackOffice.Controllers
public IActionResult PostDisableUsers([FromQuery]int[] userIds)
{
var tryGetCurrentUserId = _backofficeSecurityAccessor.BackOfficeSecurity.GetUserId();
- if (tryGetCurrentUserId && userIds.Contains(tryGetCurrentUserId.Result))
+ if (tryGetCurrentUserId.Success && userIds.Contains(tryGetCurrentUserId.Result.Value))
{
return ValidationProblem("The current user cannot disable itself");
}
diff --git a/src/Umbraco.Web.BackOffice/Filters/CheckIfUserTicketDataIsStaleAttribute.cs b/src/Umbraco.Web.BackOffice/Filters/CheckIfUserTicketDataIsStaleAttribute.cs
index 82c9e15ed5..5b3b877bb9 100644
--- a/src/Umbraco.Web.BackOffice/Filters/CheckIfUserTicketDataIsStaleAttribute.cs
+++ b/src/Umbraco.Web.BackOffice/Filters/CheckIfUserTicketDataIsStaleAttribute.cs
@@ -118,7 +118,13 @@ namespace Umbraco.Cms.Web.BackOffice.Filters
return;
}
- IUser user = _userService.GetUserById(identity.GetId());
+ var id = identity.GetId();
+ if (id is null)
+ {
+ return;
+ }
+
+ IUser user = _userService.GetUserById(id.Value);
if (user == null)
{
return;
diff --git a/src/Umbraco.Web.BackOffice/Filters/ContentModelValidator.cs b/src/Umbraco.Web.BackOffice/Filters/ContentModelValidator.cs
index a1705bcedf..5aea9bb950 100644
--- a/src/Umbraco.Web.BackOffice/Filters/ContentModelValidator.cs
+++ b/src/Umbraco.Web.BackOffice/Filters/ContentModelValidator.cs
@@ -176,7 +176,7 @@ namespace Umbraco.Cms.Web.BackOffice.Filters
if (property.DataType is null) throw new InvalidOperationException($"{nameof(property)}.{nameof(property.DataType)} cannot be null");
foreach (var validationResult in PropertyValidationService.ValidatePropertyValue(
- editor, property.DataType, postedValue, property.IsRequired,
+ editor, property.DataType, postedValue, property.IsRequired ?? false,
property.ValidationRegExp, property.IsRequiredMessage, property.ValidationRegExpMessage))
{
AddPropertyError(model, modelWithProperties, editor, property, validationResult, modelState);
diff --git a/src/Umbraco.Web.BackOffice/HealthChecks/HealthCheckController.cs b/src/Umbraco.Web.BackOffice/HealthChecks/HealthCheckController.cs
index 82029eb8c5..eae1c7d2ce 100644
--- a/src/Umbraco.Web.BackOffice/HealthChecks/HealthCheckController.cs
+++ b/src/Umbraco.Web.BackOffice/HealthChecks/HealthCheckController.cs
@@ -99,7 +99,7 @@ namespace Umbraco.Cms.Web.BackOffice.HealthChecks
return check.ExecuteAction(action);
}
- private HealthCheck GetCheckById(Guid id)
+ private HealthCheck GetCheckById(Guid? id)
{
HealthCheck check = _checks
.Where(x => _disabledCheckIds.Contains(x.Id) == false)
diff --git a/src/Umbraco.Web.BackOffice/Security/ConfigureBackOfficeCookieOptions.cs b/src/Umbraco.Web.BackOffice/Security/ConfigureBackOfficeCookieOptions.cs
index 58a6862300..66c3cecbae 100644
--- a/src/Umbraco.Web.BackOffice/Security/ConfigureBackOfficeCookieOptions.cs
+++ b/src/Umbraco.Web.BackOffice/Security/ConfigureBackOfficeCookieOptions.cs
@@ -173,7 +173,7 @@ namespace Umbraco.Cms.Web.BackOffice.Security
// generate a session id and assign it
// create a session token - if we are configured and not in an upgrade state then use the db, otherwise just generate one
Guid session = _runtimeState.Level == RuntimeLevel.Run
- ? _userService.CreateLoginSession(backOfficeIdentity.GetId(), _ipResolver.GetCurrentRequestIpAddress())
+ ? _userService.CreateLoginSession(backOfficeIdentity.GetId().Value, _ipResolver.GetCurrentRequestIpAddress())
: Guid.NewGuid();
// add our session claim
diff --git a/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs b/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs
index 3dd303d8f7..de480afdd2 100644
--- a/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs
+++ b/src/Umbraco.Web.BackOffice/Trees/ContentTreeController.cs
@@ -137,7 +137,7 @@ namespace Umbraco.Cms.Web.BackOffice.Trees
node.AdditionalData.Add("variesByCulture", documentEntity.Variations.VariesByCulture());
node.AdditionalData.Add("contentType", documentEntity.ContentTypeAlias);
- if (_publicAccessService.IsProtected(entity.Path))
+ if (_publicAccessService.IsProtected(entity.Path).Success)
node.SetProtectedStyle();
return node;
diff --git a/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs b/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs
index 2b83d1e33a..d8dc5a66fe 100644
--- a/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs
+++ b/src/Umbraco.Web.Common/Middleware/UmbracoRequestMiddleware.cs
@@ -130,7 +130,7 @@ namespace Umbraco.Cms.Web.Common.Middleware
try
{
// Verbose log start of every request
- LogHttpRequest.TryGetCurrentHttpRequestId(out Guid httpRequestId, _requestCache);
+ LogHttpRequest.TryGetCurrentHttpRequestId(out Guid? httpRequestId, _requestCache);
_logger.LogTrace("Begin request [{HttpRequestId}]: {RequestUrl}", httpRequestId, pathAndQuery);
try
@@ -160,7 +160,7 @@ namespace Umbraco.Cms.Web.Common.Middleware
{
// Verbose log end of every request (in v8 we didn't log the end request of ALL requests, only the front-end which was
// strange since we always logged the beginning, so now we just log start/end of all requests)
- LogHttpRequest.TryGetCurrentHttpRequestId(out Guid httpRequestId, _requestCache);
+ LogHttpRequest.TryGetCurrentHttpRequestId(out Guid? httpRequestId, _requestCache);
_logger.LogTrace("End Request [{HttpRequestId}]: {RequestUrl} ({RequestDuration}ms)", httpRequestId, pathAndQuery, DateTime.Now.Subtract(umbracoContextReference.UmbracoContext.ObjectCreated).TotalMilliseconds);
try
diff --git a/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs b/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs
index 9ea0728ce5..13ff104265 100644
--- a/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs
+++ b/src/Umbraco.Web.Common/Security/BackofficeSecurity.cs
@@ -38,8 +38,12 @@ namespace Umbraco.Cms.Web.Common.Security
//Check again
if (_currentUser == null)
{
- Attempt id = GetUserId();
- _currentUser = id ? _userService.GetUserById(id.Result) : null;
+ Attempt id = GetUserId();
+ if (id.Success && id.Result is not null)
+ {
+ _currentUser = id.Success ? _userService.GetUserById(id.Result.Value) : null;
+ }
+
}
}
}
@@ -49,10 +53,10 @@ namespace Umbraco.Cms.Web.Common.Security
}
///
- public Attempt GetUserId()
+ public Attempt GetUserId()
{
ClaimsIdentity identity = _httpContextAccessor.HttpContext?.GetCurrentIdentity();
- return identity == null ? Attempt.Fail() : Attempt.Succeed(identity.GetId());
+ return identity == null ? Attempt.Fail() : Attempt.Succeed(identity.GetId());
}
///
diff --git a/src/Umbraco.Web.Common/Security/MemberManager.cs b/src/Umbraco.Web.Common/Security/MemberManager.cs
index 52bfd6a58b..e73a15f989 100644
--- a/src/Umbraco.Web.Common/Security/MemberManager.cs
+++ b/src/Umbraco.Web.Common/Security/MemberManager.cs
@@ -162,7 +162,7 @@ namespace Umbraco.Cms.Web.Common.Security
foreach (var path in paths)
{
//this is a cached call
- result[path] = _publicAccessService.IsProtected(path);
+ result[path] = _publicAccessService.IsProtected(path).Success;
}
return Task.FromResult((IReadOnlyDictionary)result);
}
diff --git a/src/Umbraco.Web.Website/Routing/PublicAccessRequestHandler.cs b/src/Umbraco.Web.Website/Routing/PublicAccessRequestHandler.cs
index d70bc6ce5d..4c1f6acd99 100644
--- a/src/Umbraco.Web.Website/Routing/PublicAccessRequestHandler.cs
+++ b/src/Umbraco.Web.Website/Routing/PublicAccessRequestHandler.cs
@@ -63,7 +63,7 @@ namespace Umbraco.Cms.Web.Website.Routing
Attempt publicAccessAttempt = _publicAccessService.IsProtected(path);
- if (publicAccessAttempt)
+ if (publicAccessAttempt.Success)
{
_logger.LogDebug("EnsurePublishedContentAccess: Page is protected, check for access");