This is what I am trying to do,
If the user is authenticated in sitecore, and not authenticated in external system then log out the user from sitecore.
So, here is the pipeline I use:
<processor patch:after="*[@type='Sitecore.Pipelines.HttpRequest.UserResolver, Sitecore.Kernel']" type="xxx.SitecoreExtensions.Pipelines.HttpRequest.ExternalSystemUserAuthenticationResolver, xxx.SitecoreExtensions">
The processor xxx.SitecoreExtensions.Pipelines.HttpRequest.ExternalSystemUserAuthenticationResolver
reads some data from Session and returns true or false if the external system token is present in session or not.
This is what is happening:
When I sign in (sign in logs me in both the systems, sitecore and external), a token is set in the session and the ExternalSystemUserAuthenticationResolver
method gives me correct status of authentication. When I am redirected to other page after login, the ExternalSystemUserAuthenticationResolver
method does not find anything in session and says that I am not logged into external system so the overall authentication status is false.
Here is the implementation of the new method:
public class ExternalSystemUserAuthenticationResolver: HttpRequestProcessor
{
protected override void SiteSpecificProcess(HttpRequestArgs args)
{
try
{
if (Sitecore.Context.User.IsAuthenticated && !AccountHelper.IsExternalSystemAuthenticated())
{
AuthenticationManager.Logout();
}
}
catch (Exception ex)
{
Log.Error(ex.Message, ex, this);
}
}
}
AccountHelper.IsExternalSystemAuthenticated()
reads data from the session to check if the token and if the session is null then I am redirected to another page after login.
Where should I place my new processor so that the session object is populated?