microsoft / CopilotStudioSamples

MIT License
301 stars 247 forks source link

SSO will fail when email is not identical to login #185

Open adilei opened 6 months ago

adilei commented 6 months ago

What sample tool are you using? SharePoint SSO Component

Describe the bug Currently, the SharePoint SSO Component uses userEmail to build a token request. For organizations where email addresses and login names are not identical, this is likely to fail.

See this issue: https://github.com/microsoft/CopilotStudioSamples/issues/182

sudburyr0x commented 3 months ago

Is there an easy fix to this to use the login name instead? Currently facing this issue. Thank you!

adilei commented 3 months ago

In pvaSso/PvaSsoApplicationCustomizer.ts line 116, change user.Email to user.loginName

  private _renderPlaceHolders(): void {
    // Handling the bottom placeholder
    if (!this._bottomPlaceholder) {
      this._bottomPlaceholder = this.context.placeholderProvider.tryCreateContent(
        PlaceholderName.Bottom,
        { onDispose: this._onDispose }
      );

      // The extension should not assume that the expected placeholder is available.
      if (!this._bottomPlaceholder) {
        console.error("The expected placeholder (Bottom) was not found.");
        return;
      }
      const user = this.context.pageContext.user;
      const elem: React.ReactElement = React.createElement<IChatbotProps>(Chatbot, { ...this.properties, **userEmail: user.email**, userFriendlyName: user.displayName });  
      ReactDOM.render(elem, this._bottomPlaceholder.domElement);
    }