|
@@ -37,7 +37,7 @@ public class DefaultSessionContext : ISessionContext, IScopeDependency
|
|
|
/// </summary>
|
|
|
public string? UserId
|
|
|
{
|
|
|
- get { return _contextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier); }
|
|
|
+ get { return _contextAccessor.HttpContext?.User.FindFirstValue(ClaimTypes.NameIdentifier); }
|
|
|
init { }
|
|
|
}
|
|
|
|
|
@@ -48,7 +48,7 @@ public class DefaultSessionContext : ISessionContext, IScopeDependency
|
|
|
public string RequiredUserId => _contextAccessor.HttpContext.User.FindFirstValue(ClaimTypes.NameIdentifier);
|
|
|
public string? UserName
|
|
|
{
|
|
|
- get { return _contextAccessor.HttpContext.User.FindFirstValue(AppClaimTypes.UserDisplayName); }
|
|
|
+ get { return _contextAccessor.HttpContext?.User.FindFirstValue(AppClaimTypes.UserDisplayName); }
|
|
|
init { }
|
|
|
}
|
|
|
|
|
@@ -63,26 +63,26 @@ public class DefaultSessionContext : ISessionContext, IScopeDependency
|
|
|
/// </summary>
|
|
|
public string[] Roles
|
|
|
{
|
|
|
- get { return _contextAccessor.HttpContext.User.Claims.Where(d => d.Type == ClaimTypes.Role).Select(d => d.Value).ToArray(); }
|
|
|
+ get { return _contextAccessor.HttpContext?.User.Claims.Where(d => d.Type == ClaimTypes.Role).Select(d => d.Value).ToArray(); }
|
|
|
init { }
|
|
|
}
|
|
|
|
|
|
public string? OrgId
|
|
|
{
|
|
|
- get { return _contextAccessor.HttpContext.User.FindFirstValue(AppClaimTypes.DepartmentId); }
|
|
|
+ get { return _contextAccessor.HttpContext?.User.FindFirstValue(AppClaimTypes.DepartmentId); }
|
|
|
init { }
|
|
|
}
|
|
|
|
|
|
- public string RequiredOrgId => _contextAccessor.HttpContext.User.FindFirstValue(AppClaimTypes.DepartmentId);
|
|
|
+ public string RequiredOrgId => _contextAccessor.HttpContext?.User.FindFirstValue(AppClaimTypes.DepartmentId);
|
|
|
public string? OrgName
|
|
|
{
|
|
|
- get { return _contextAccessor.HttpContext.User.FindFirstValue(AppClaimTypes.DepartmentName); }
|
|
|
+ get { return _contextAccessor.HttpContext?.User.FindFirstValue(AppClaimTypes.DepartmentName); }
|
|
|
init { }
|
|
|
}
|
|
|
|
|
|
public int OrgLevel
|
|
|
{
|
|
|
- get { return _contextAccessor.HttpContext.User.FindIntValue(AppClaimTypes.DepartmentLevel); }
|
|
|
+ get { return _contextAccessor.HttpContext?.User.FindIntValue(AppClaimTypes.DepartmentLevel) ?? 0; }
|
|
|
init { }
|
|
|
}
|
|
|
|
|
@@ -109,7 +109,7 @@ public class DefaultSessionContext : ISessionContext, IScopeDependency
|
|
|
|
|
|
public string? AreaId
|
|
|
{
|
|
|
- get { return _contextAccessor.HttpContext.User.FindFirstValue(AppClaimTypes.AreaId); }
|
|
|
+ get { return _contextAccessor.HttpContext?.User.FindFirstValue(AppClaimTypes.AreaId); }
|
|
|
init { }
|
|
|
}
|
|
|
public string? ClientId
|