mirror of https://github.com/abpframework/abp.git
3 changed files with 35 additions and 26 deletions
@ -0,0 +1,26 @@ |
|||||
|
using System; |
||||
|
using JetBrains.Annotations; |
||||
|
|
||||
|
namespace Volo.Abp.Session |
||||
|
{ |
||||
|
public static class CurrentUserExtensions |
||||
|
{ |
||||
|
[CanBeNull] |
||||
|
public static string FindClaimValue(this ICurrentUser currentUser, string claimType) |
||||
|
{ |
||||
|
return currentUser.FindClaim(claimType)?.Value; |
||||
|
} |
||||
|
|
||||
|
public static T FindClaimValue<T>(this ICurrentUser currentUser, string claimType) |
||||
|
where T : struct |
||||
|
{ |
||||
|
var value = currentUser.FindClaimValue(claimType); |
||||
|
if (value == null) |
||||
|
{ |
||||
|
return default; |
||||
|
} |
||||
|
|
||||
|
return value.To<T>(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue