Sitecore / jss

Software development kit for JavaScript developers building web applications with Sitecore Experience Platform
https://jss.sitecore.com
Apache License 2.0
262 stars 272 forks source link

How can you get the current authenticated user? #298

Closed reinvanleirsberghe closed 2 years ago

reinvanleirsberghe commented 4 years ago

Using the docs on https://jss.sitecore.com/docs/techniques/authentication/sitecore-auth I have managed to login on my angular app.

Now I want to get my profile settings. How can you get the current authenticated userId? The only thing that is set is the cookie with a value, but I can't do anything with this value...

Thanks in advance!

alexshyba commented 4 years ago

Hi @reinvanleirsberghe

You can bring profile settings from the server by extending LayoutService context, here is the doc that provides an example. This would require some .NET coding :) https://jss.sitecore.com/docs/techniques/extending-layout-service/layoutservice-extending-context#extending-context-data-returned-by-the-layout-service

erzr commented 4 years ago

Here's an example of using GraphQL to accomplish this as well: https://github.com/erzr/JssAuthenticationSSC

anastasiya29 commented 4 years ago

Creating a JS function for components to optionally use that would wrap the layout service response with user data would be a nice enhancement to the current behavior. I've added the appropriate label.

nickwesselman commented 3 years ago

When the current user is logged in, the domain and user are included in the LS Context. Can this be closed?

stale[bot] commented 2 years ago

This has been automatically marked as stale because it has not had recent activity. It will be closed if there is no further activity within 30 days. You may add comments or the 'keep' label to prevent it from closing. Thank you for your contributions.