From 02cd475908da7782c05109151ecd63649a295a9e Mon Sep 17 00:00:00 2001 From: martincostello Date: Tue, 1 Nov 2022 14:15:54 +0000 Subject: [PATCH] Huawei provider tweaks - Rename `FetchNickName` to `FetchNickname`. - Add missing XML documentation. - Remove documentation copied from Huawei that isn't provider-specific. --- docs/huawei.md | 13 ++++--------- .../HuaweiAuthenticationHandler.cs | 2 +- .../HuaweiAuthenticationOptions.cs | 5 ++++- .../Huawei/HuaweiTests.cs | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/docs/huawei.md b/docs/huawei.md index 2a27f5229..4f287c668 100644 --- a/docs/huawei.md +++ b/docs/huawei.md @@ -9,12 +9,12 @@ services.AddAuthentication(options => /* Auth configuration */) options.ClientId = "my-client-id"; options.ClientSecret = "my-client-secret"; - // Optionally. + // Optionally return the user's profile and email address options.Scope.Add("profile"); options.Scope.Add("email"); - // Optionally. - options.FetchNickName = true; + // Optionally get the user's nickname + options.FetchNickname = true; }); ``` @@ -26,9 +26,4 @@ _None._ | Property Name | Property Type | Description | Default Value | |:--|:--|:--|:--| -| `FetchNickName` | `bool` | When FetchNickName is set to false or not set, the anonymous account is returned. If the anonymous account is unavailable, the nickname is returned. When FetchNickName is set to true, the nickname is returned. If the nickname is unavailable, the anonymous account is returned. | `false` | - -### Scope -Corresponding information, such as the profile picture and email address, can be obtained only if the app has the permission to obtain the information. -* `profile` basic information of a HUAWEI ID, such as the profile picture and nickname. -* `email` email address of a HUAWEI ID. +| `FetchNickname` | `bool` | When `false` the anonymous account is returned. If the anonymous account is unavailable, the nickname is returned. When `true`, the nickname is returned. If the nickname is unavailable, the anonymous account is returned. | `false` | diff --git a/src/AspNet.Security.OAuth.Huawei/HuaweiAuthenticationHandler.cs b/src/AspNet.Security.OAuth.Huawei/HuaweiAuthenticationHandler.cs index 7bb4a30fb..232530c30 100644 --- a/src/AspNet.Security.OAuth.Huawei/HuaweiAuthenticationHandler.cs +++ b/src/AspNet.Security.OAuth.Huawei/HuaweiAuthenticationHandler.cs @@ -33,7 +33,7 @@ protected override async Task CreateTicketAsync( var content = new FormUrlEncodedContent(new[] { - new KeyValuePair("getNickName", Options.FetchNickName ? "1" : "0"), + new KeyValuePair("getNickName", Options.FetchNickname ? "1" : "0"), new KeyValuePair("access_token", tokens.AccessToken!) }); diff --git a/src/AspNet.Security.OAuth.Huawei/HuaweiAuthenticationOptions.cs b/src/AspNet.Security.OAuth.Huawei/HuaweiAuthenticationOptions.cs index e58e1c9f1..43b52d2b7 100644 --- a/src/AspNet.Security.OAuth.Huawei/HuaweiAuthenticationOptions.cs +++ b/src/AspNet.Security.OAuth.Huawei/HuaweiAuthenticationOptions.cs @@ -31,5 +31,8 @@ public HuaweiAuthenticationOptions() Scope.Add("openid"); } - public bool FetchNickName { get; set; } + /// + /// Gets or sets a value indicating whether to use the user's nickname, if available. + /// + public bool FetchNickname { get; set; } } diff --git a/test/AspNet.Security.OAuth.Providers.Tests/Huawei/HuaweiTests.cs b/test/AspNet.Security.OAuth.Providers.Tests/Huawei/HuaweiTests.cs index 96637963f..513c55d64 100644 --- a/test/AspNet.Security.OAuth.Providers.Tests/Huawei/HuaweiTests.cs +++ b/test/AspNet.Security.OAuth.Providers.Tests/Huawei/HuaweiTests.cs @@ -19,7 +19,7 @@ protected internal override void RegisterAuthentication(AuthenticationBuilder bu { builder.AddHuawei(options => { - options.FetchNickName = true; + options.FetchNickname = true; options.Scope.Add("profile"); options.Scope.Add("email");