Fixed build errors after turning nullability errors off

This commit is contained in:
Nikolaj Geisle
2022-02-10 10:32:45 +01:00
parent b75eae01f3
commit 83baba696c
39 changed files with 91 additions and 69 deletions

View File

@@ -38,8 +38,12 @@ namespace Umbraco.Cms.Web.Common.Security
//Check again
if (_currentUser == null)
{
Attempt<int> id = GetUserId();
_currentUser = id ? _userService.GetUserById(id.Result) : null;
Attempt<int?> 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
}
/// <inheritdoc />
public Attempt<int> GetUserId()
public Attempt<int?> GetUserId()
{
ClaimsIdentity identity = _httpContextAccessor.HttpContext?.GetCurrentIdentity();
return identity == null ? Attempt.Fail<int>() : Attempt.Succeed(identity.GetId());
return identity == null ? Attempt.Fail<int?>() : Attempt.Succeed(identity.GetId());
}
/// <inheritdoc />

View File

@@ -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<string, bool>)result);
}