sp-dev-docs icon indicating copy to clipboard operation
sp-dev-docs copied to clipboard

Unreliable legacyPageContext.userId

Open dg2000r opened this issue 7 years ago • 3 comments

Category

  • [ ] Question
  • [ ] Typo
  • [x] Bug
  • [ ] Additional article idea

Expected or Desired Behavior

As pageContext doesn't contain an ID number, we have to use this.context.pageContext.legacyPageContext.userId to return a value unique to a particular user, as has been possible for previous versions of SP

Observed Behavior

We have several sites on the same tenant eg. https://ourtenant.sharepoint.com/sites/site1 https://ourtenant.sharepoint.com/sites/site2 https://ourtenant.sharepoint.com/sites/site3

The value returned by legacyPageContext.userId is different depending on which site I visit (although the other user values such as username/email etc. are consistent as expected).

The value stays the same for all pages in a specific site, but changes when I browse to another site. Some sites do return the same userID, eg. site1 and site2 return a value of '10', but site3 returns a value of '9'.

Steps to Reproduce

Browse to any page and log the user ID value.

dg2000r avatar Mar 19 '19 13:03 dg2000r

Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.

msft-github-bot avatar Mar 19 '19 13:03 msft-github-bot

Correct. The UserId in the legacy page context points to the userId field, which is dependent on the site you are on. Ie, it is it userid for that user in that site. There are some APIs that require this value. The information like loginName, email, etc. would be consistent across sites.

patmill avatar Mar 19 '19 14:03 patmill

Issues that have been closed & had no follow-up activity for at least 7 days are automatically locked. Please refer to our wiki for more details, including how to remediate this action if you feel this was done prematurely or in error: Issue List: Our approach to locked issues

msft-github-bot avatar Jan 25 '20 00:01 msft-github-bot