microsoftgraph / microsoft-graph-toolkit

Authentication Providers and UI components for Microsoft Graph 🦒
https://docs.microsoft.com/graph/toolkit/overview
Other
943 stars 300 forks source link

[BUG] mgt-person not working for unlicenced users (users without email) #3149

Closed Rafaelki closed 2 months ago

Rafaelki commented 6 months ago

Describe the bug For users without email, the mgt-person component doesn't render. Would it be possible to replace the query so that it asks by login account instead of email?

To Reproduce Steps to reproduce the behavior:

  1. Create a user without any license
  2. Use the mgt-person component indicating a user without outlook licence

Expected behavior I expect to see the avatar of the user

Environment (please complete the following information):

musale commented 4 months ago

You can set the value you want to use using person-query property.

<mgt-person person-query="me" view="threelines"></mgt-person>
<mgt-person person-query="MeganB@M365x214355.onmicrosoft.com" view="threelines"></mgt-person>
<mgt-person person-query="Megan Bowen" view="threelines"></mgt-person>

What value are you seeking to use when you say login account?

musale commented 4 months ago

Ping @Rafaelki, did this issue get resolved for you?

Rafaelki commented 3 months ago

Hi @musale , sorry the late response.

I am using person-query, like <mgt-person person-query="MeganB@M365x214355.onmicrosoft.com" view="threelines"></mgt-person>

But it fails (nothing gets rendered) if the user doesn't have an email account, ie. for users without Outlook licence.

This is because the code is making a call searching by email:

graph.microsoft.com/v1.0/users?$search=%22displayName:XXXXX%22%20OR%20%22mail:XXXXX%22&$count=true&$top=1

Would it be possible to change that query (and any other that uses mail) to use userPrincipalName as a filter instead of mail? I have tested the query in Graph explorer and works fine for both users with email and without email:

graph.microsoft.com/v1.0/users?$search=%22displayName:XXXXX%22%20OR%20%22userPrincipalName:XXXXX%22&$count=true&$top=1

musale commented 3 months ago

@Rafaelki oh I see it. Please test if a query like this: ?search=displayName:xxxORmail:xxxORuserPrincipalName:xxx works on GE for you. If it does, then this can be added on the query string we make.

Rafaelki commented 3 months ago

Hi @musale, thanks for your quick answer. Yes, having the 3 clauses works as expected. Could you review if you have other queries using "mail" and apply the same fix? Thanks a lot!

musale commented 3 months ago

@Rafaelki no other area requires this update.

Rafaelki commented 2 months ago

Hi @musale , could you please reopen this bug? There is a space in the query so it is not working properly.

image

image

Rafaelki commented 2 months ago

Hi @musale, just checking if you have seen this... I am not sure if the procedure after a bug is closed, do you prefer that I open a separate bug?

Mnickii commented 2 months ago

Reopening this as there is a space in the query so it is not working properly @musale