0

We had implemented federated authentication on CD site by using LinkedIn identity provider, we followed this great blog post "https://josedbaez.com/2018/03/sitecore9-sso/" which described each step very clearly.

The user is able to do the login to our site using LinkedIn account, we have login component on every page, so when user initiate login he gets redirected to home page after successful login, but we want to redirect user on same page from where he initiate login.

In OAuth redirect url setting we had mention our home page url, so without adding too many urls to that setting can we redirect user to same page from where he initiate login?

2

From the above blog post I can see that you are using getSignInUrlInfo in LoginLinksController, where you are passing the returnurl as "/",

var url = "/"
var args = new GetSignInUrlInfoArgs("website", url);
GetSignInUrlInfoPipeline.Run(corePipelineManager, args);

You need to get the current Item URL in the controller, here and then you can pass it in the same arguments.
you can get the current URL in multiple ways such as using LinkManager-

var url = Sitecore.Links.LinkManager.GetItemUrl(Sitecore.Context.Item);

or using PageContext

var url = PageContext.Current.Item;
| improve this answer | |
  • thanks mahendra , its work perfectly ! just need to know one more thing if you can help in that , even after successful login i am getting IsAuthenticated as false and also i am not able map properties , i have added properties to property initializer. Because of this i am not getting any values in UserProfile. – Sam Aug 1 '19 at 8:49
  • usually, this happens when you don't have a unique claim name – Mahendra Shekhawat Aug 1 '19 at 8:58
  • ok thanks mahendra i will check my claim! – Sam Aug 1 '19 at 9:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.