Skip to content

Commit ac27bd5

Browse files
authored
Append FAQ address to AAD unmanaged tenant authentication error (#7993)
Append FAQ address to AAD unmanaged tenant authentication error
1 parent 020aed8 commit ac27bd5

4 files changed

Lines changed: 29 additions & 3 deletions

File tree

src/NuGetGallery/Controllers/AuthenticationController.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -811,9 +811,22 @@ private string GetEmailAddressFromExternalLoginResult(AuthenticateExternalLoginR
811811

812812
private ActionResult AuthenticationFailureOrExternalLinkExpired(string errorMessage = null)
813813
{
814-
// User got here without an external login cookie (or an expired one)
815-
// Send them to the logon action with a message
816-
TempData["ErrorMessage"] = string.IsNullOrEmpty(errorMessage) ? Strings.ExternalAccountLinkExpired : errorMessage;
814+
// We need a special case here because of https://github.com/NuGet/NuGetGallery/issues/7544. An unmanaged tenant scenario
815+
// needs the FAQ URI appended to the AAD error, and we do that here so it appears in the header.
816+
if (!string.IsNullOrEmpty(errorMessage) &&
817+
errorMessage.IndexOf("AADSTS65005", StringComparison.OrdinalIgnoreCase) > -1 &&
818+
errorMessage.IndexOf("unmanaged", StringComparison.OrdinalIgnoreCase) > -1)
819+
{
820+
TempData["RawErrorMessage"] = errorMessage + "<br/>" + string.Format(Strings.DirectUserToUnmanagedTenantFAQ,
821+
UriExtensions.GetExternalUrlAnchorTag("FAQs page", GalleryConstants.FAQLinks.AccountBelongsToUnmanagedTenant));
822+
}
823+
else
824+
{
825+
// User got here without an external login cookie (or an expired one)
826+
// Send them to the logon action with a message
827+
TempData["ErrorMessage"] = string.IsNullOrEmpty(errorMessage) ? Strings.ExternalAccountLinkExpired : errorMessage;
828+
}
829+
817830
return Redirect(Url.LogOn(null, relativeUrl: false));
818831
}
819832

src/NuGetGallery/GalleryConstants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ public static class FAQLinks
113113
public const string NuGetChangeUsername = "https://aka.ms/nuget-faq-change-username";
114114
public const string NuGetDeleteAccount = "https://aka.ms/nuget-faq-delete-account";
115115
public const string TransformToOrganization = "https://aka.ms/nuget-faq-transform-org";
116+
public const string AccountBelongsToUnmanagedTenant = "https://aka.ms/nuget-faq-unmanaged-tenant";
116117
}
117118
}
118119
}

src/NuGetGallery/Strings.Designer.cs

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/NuGetGallery/Strings.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -693,6 +693,9 @@ For more information, please contact '{2}'.</value>
693693
<value>The account with the email {0} is linked to another Microsoft account.
694694
If you would like to update the linked Microsoft account you can do so from the account settings page.</value>
695695
</data>
696+
<data name="DirectUserToUnmanagedTenantFAQ" xml:space="preserve">
697+
<value>Please refer to the {0} for steps to resolve this issue.</value>
698+
</data>
696699
<data name="ChangeCredential_Failed" xml:space="preserve">
697700
<value>Failed to update the Microsoft account with '{0}'. This could happen if it is already linked to another NuGet account. See {1} for more details.</value>
698701
</data>

0 commit comments

Comments
 (0)