Login ActionFilter.OnActionExecuted not returning logged in user

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
Hace 7 años
I need to do additional processing after the user is logged in.

I have created an action filter:

public IEnumerable<Filter> GetFilters(ControllerContext controllerContext, ActionDescriptor actionDescriptor)
{
  if (actionDescriptor.ControllerDescriptor.ControllerType == typeof(Web.Controllers.CustomerController)
    && actionDescriptor.ActionName.Equals("Login")
    && controllerContext.HttpContext.Request.HttpMethod == "POST")
  {
    return new List<Filter>() { new Filter(this, FilterScope.Action, 0) };
  }
  
  return new List<Filter>();
}

public override void OnActionExecuted(ActionExecutedContext filterContext)
{
  string username = filterContext.HttpContext.User.Identity.Name;
  var workContext = EngineContext.Current.Resolve<IWorkContext>();
  var customer = workContext.CurrentCustomer;
  if (customer != null && !customer.IsGuest() && customer.IsRegistered())
  {
    
  }
  base.OnActionExecuted(filterContext);
}


The code in the OnActionExecuted is my attempts to get the logged in user but so far it only returns the guest user.
Hace 7 años
Someone else asked the same question recently, I suggested using the CustomerLoggedInEvent instead: https://www.nopcommerce.com/boards/t/46371/overriding-register-and-my-account.aspx?p=2#184192
Hace 7 años
That is exactly what I needed.

Thanks for the quick reply!
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.