Unreliable legacyPageContext.userId
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.
Thank you for reporting this issue. We will be triaging your incoming issue as soon as possible.
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.
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