|
@@ -24,10 +24,10 @@ namespace MTWorkHR.Application.Filters
|
|
|
var cc = context.HttpContext.User.Identities.FirstOrDefault();
|
|
|
var cc2 = cc.Claims.FirstOrDefault(c => c.Type.Contains( "email"));
|
|
|
var email = cc2 != null ? cc2.Value : "";
|
|
|
- var generatedGuid = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("Jti").Value;
|
|
|
+ var generatedGuid = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("Jti")?.Value;
|
|
|
var companyId = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("companyId")?.Value;
|
|
|
- var userId = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("uid").Value;
|
|
|
- var userName = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("name").Value;
|
|
|
+ var userId = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("uid")?.Value;
|
|
|
+ var userName = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("name")?.Value;
|
|
|
// var email1 = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("emailaddress").Value;
|
|
|
// var email2 = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("email").Value;
|
|
|
// var hierarchyIds = context.HttpContext.User.Identities.FirstOrDefault().FindFirst("hierarchyIds").Value;
|
|
@@ -54,7 +54,12 @@ namespace MTWorkHR.Application.Filters
|
|
|
globalInfo.SetValues( userName, userId, companyId !=null && companyId != "" ? long.Parse(companyId) : null , token, lang);
|
|
|
|
|
|
var userManager = context.HttpContext.RequestServices.GetService<ApplicationUserManager>();
|
|
|
-
|
|
|
+ bool hasAllowAnonymousFlag = context.ActionDescriptor.EndpointMetadata
|
|
|
+ .Any(em => em.GetType() == typeof(AllowAnonymousAttribute));
|
|
|
+ if (hasAllowAnonymousFlag)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
//check if user blocked
|
|
|
if (await userManager.IsStopped(userId))
|
|
|
{
|