Skip to content

Commit c288d03

Browse files
Zeegaanbergmania
andauthored
v14: TryGetUmbracouser default implementation (#16899)
* Add default implementation * Update src/Umbraco.Core/Security/Authorization/IAuthorizationHelper.cs Co-authored-by: Bjarke Berg <[email protected]> --------- Co-authored-by: Bjarke Berg <[email protected]>
1 parent 35d6fc2 commit c288d03

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/Umbraco.Core/Security/Authorization/IAuthorizationHelper.cs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,17 @@ public interface IAuthorizationHelper
2424
/// <param name="currentUser">The current user's principal.</param>
2525
/// <param name="user">The resulting <see cref="IUser" />, if the conversion is successful.</param>
2626
/// <returns>True if the conversion is successful, false otherwise</returns>
27-
bool TryGetUmbracoUser(IPrincipal currentUser, [NotNullWhen(true)] out IUser? user);
27+
bool TryGetUmbracoUser(IPrincipal currentUser, [NotNullWhen(true)] out IUser? user)
28+
{
29+
try
30+
{
31+
user = GetUmbracoUser(currentUser);
32+
return true;
33+
}
34+
catch
35+
{
36+
user = null;
37+
return false;
38+
}
39+
}
2840
}

0 commit comments

Comments
 (0)