diff --git a/README.en.md b/README.en.md index 06aa98334..bf2f6d5f8 100644 --- a/README.en.md +++ b/README.en.md @@ -140,6 +140,7 @@ Read what we [milestones](https://github.com/SteamTools-Team/SteamTools/mileston * [NPOI](https://github.com/nissl-lab/npoi) * [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) * [AspNet.Security.OpenId.Providers](https://github.com/aspnet-contrib/AspNet.Security.OpenId.Providers) +* [AspNet.Security.OAuth.Providers](https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers) * [CefNet](https://github.com/CefNet/CefNet) * [CefSharp](https://github.com/cefsharp/CefSharp) * [React](https://github.com/facebook/react) diff --git a/README.md b/README.md index 50a783e39..cd3ed4f87 100644 --- a/README.md +++ b/README.md @@ -152,6 +152,7 @@ * [NPOI](https://github.com/nissl-lab/npoi) * [Swashbuckle.AspNetCore](https://github.com/domaindrivendev/Swashbuckle.AspNetCore) * [AspNet.Security.OpenId.Providers](https://github.com/aspnet-contrib/AspNet.Security.OpenId.Providers) +* [AspNet.Security.OAuth.Providers](https://github.com/aspnet-contrib/AspNet.Security.OAuth.Providers) * [CefNet](https://github.com/CefNet/CefNet) * [CefSharp](https://github.com/cefsharp/CefSharp) * [React](https://github.com/facebook/react) diff --git a/src/ST.Services.CloudService.Models/Models/BindPhoneNumberRequest.cs b/src/ST.Services.CloudService.Models/Models/BindPhoneNumberRequest.cs new file mode 100644 index 000000000..b16c8312b --- /dev/null +++ b/src/ST.Services.CloudService.Models/Models/BindPhoneNumberRequest.cs @@ -0,0 +1,28 @@ +using System.Application.Columns; +using MPKey = MessagePack.KeyAttribute; +using MPObj = MessagePack.MessagePackObjectAttribute; +using N_JsonProperty = Newtonsoft.Json.JsonPropertyAttribute; +using S_JsonProperty = System.Text.Json.Serialization.JsonPropertyNameAttribute; + +namespace System.Application.Models +{ + [MPObj] + public class BindPhoneNumberRequest : IReadOnlyPhoneNumber, IReadOnlySmsCode + { + /// + /// 短信验证码 + /// + [MPKey(0)] + [N_JsonProperty("0")] + [S_JsonProperty("0")] + public string? SmsCode { get; set; } + + /// + /// 手机号码 + /// + [MPKey(1)] + [N_JsonProperty("1")] + [S_JsonProperty("1")] + public string? PhoneNumber { get; set; } + } +} \ No newline at end of file diff --git a/src/ST.Services.CloudService/Services/CloudService/Clients/Abstractions/IManageClient.cs b/src/ST.Services.CloudService/Services/CloudService/Clients/Abstractions/IManageClient.cs index c7cdecf32..49d382473 100644 --- a/src/ST.Services.CloudService/Services/CloudService/Clients/Abstractions/IManageClient.cs +++ b/src/ST.Services.CloudService/Services/CloudService/Clients/Abstractions/IManageClient.cs @@ -43,5 +43,19 @@ namespace System.Application.Services.CloudService.Clients.Abstractions /// /// Task SignOut(); + + /// + /// 绑定手机号码(通过快速登录注册的账号需要此功能) + /// + /// + /// + Task BindPhoneNumber(BindPhoneNumberRequest request); + + /// + /// 解绑账号 + /// + /// + /// + Task UnbundleAccount(FastLoginChannel channel); } } \ No newline at end of file diff --git a/src/ST.Services.CloudService/Services/CloudService/Clients/ManageClient.cs b/src/ST.Services.CloudService/Services/CloudService/Clients/ManageClient.cs index 0388744ee..77d7cbf4e 100644 --- a/src/ST.Services.CloudService/Services/CloudService/Clients/ManageClient.cs +++ b/src/ST.Services.CloudService/Services/CloudService/Clients/ManageClient.cs @@ -33,7 +33,7 @@ namespace System.Application.Services.CloudService.Clients public Task DeleteAccount() => conn.SendAsync( isAnonymous: false, - method: HttpMethod.Get, + method: HttpMethod.Delete, requestUri: "api/Manage/DeleteAccount", cancellationToken: default); @@ -65,5 +65,21 @@ namespace System.Application.Services.CloudService.Clients method: HttpMethod.Get, requestUri: "api/Manage/SignOut", cancellationToken: default); + + public Task BindPhoneNumber(BindPhoneNumberRequest request) + => conn.SendAsync( + isAnonymous: false, + isSecurity: true, + method: HttpMethod.Post, + requestUri: "api/Manage/BindPhoneNumber", + request: request, + cancellationToken: default); + + public Task UnbundleAccount(FastLoginChannel channel) + => conn.SendAsync( + isAnonymous: false, + method: HttpMethod.Delete, + requestUri: $"api/Manage/UnbundleAccount/{(int)channel}", + cancellationToken: default); } } \ No newline at end of file diff --git a/src/ST.Services.CloudService/Services/CloudService/MockCloudServiceClient.cs b/src/ST.Services.CloudService/Services/CloudService/MockCloudServiceClient.cs index e66ff6cbb..e656bedfa 100644 --- a/src/ST.Services.CloudService/Services/CloudService/MockCloudServiceClient.cs +++ b/src/ST.Services.CloudService/Services/CloudService/MockCloudServiceClient.cs @@ -93,6 +93,20 @@ namespace System.Application.Services.CloudService } } + public async Task BindPhoneNumber(BindPhoneNumberRequest request) + { + var mockDelay = false; + var rsp = ModelValidator(request) ?? BindPhoneNumber_(); + if (mockDelay) await Task.Delay(1500); + GlobalResponseIntercept(rsp); + return rsp; + IApiResponse BindPhoneNumber_() + { + mockDelay = true; + return ApiResponse.Ok(); + } + } + public Task> CheckUpdate(Guid id, Platform platform, DeviceIdiom deviceIdiom, ArchitectureFlags supportedAbis, Version osVersion, ArchitectureFlags abi) { return Task.FromResult(ApiResponse.Ok(default)); diff --git a/src/ST/FastLoginChannel.cs b/src/ST/FastLoginChannel.cs new file mode 100644 index 000000000..148ae7cc1 --- /dev/null +++ b/src/ST/FastLoginChannel.cs @@ -0,0 +1,73 @@ +namespace System.Application +{ + /// + /// 快速登录渠道 + /// + public enum FastLoginChannel + { + /// + /// https://www.nuget.org/packages/AspNet.Security.OpenId.Steam + /// + Steam, + + /// + /// https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.MicrosoftAccount + /// + Microsoft, + + /// + /// https://www.nuget.org/packages/AspNet.Security.OAuth.QQ + /// + QQ, + + /// + /// https://www.nuget.org/packages/AspNet.Security.OAuth.Apple + /// + Apple, + + ///// + ///// https://www.nuget.org/packages/AspNet.Security.OAuth.Weixin + ///// + //Weixin, + + ///// + ///// https://www.nuget.org/packages/AspNet.Security.OAuth.Weibo + ///// + //Weibo, + + ///// + ///// https://www.nuget.org/packages/AspNet.Security.OAuth.BattleNet + ///// + //BattleNet, + + ///// + ///// https://www.nuget.org/packages/AspNet.Security.OAuth.NetEase + ///// + //NetEase, + + ///// + ///// https://www.nuget.org/packages/AspNet.Security.OAuth.LinkedIn + ///// + //LinkedIn, + + ///// + ///// https://www.nuget.org/packages/AspNet.Security.OAuth.GitHub + ///// + //GitHub, + + ///// + ///// https://www.nuget.org/packages/AspNet.Security.OAuth.Discord + ///// + //Discord, + + ///// + ///// https://www.nuget.org/packages/AspNet.Security.OAuth.Baidu + ///// + //Baidu, + + ///// + ///// https://www.nuget.org/packages/AspNet.Security.OAuth.Gitee + ///// + //Gitee, + } +} \ No newline at end of file diff --git a/src/ST/SmsCodeType.cs b/src/ST/SmsCodeType.cs index b0d34753f..2fb1727c4 100644 --- a/src/ST/SmsCodeType.cs +++ b/src/ST/SmsCodeType.cs @@ -1,4 +1,4 @@ -namespace System.Application +namespace System.Application { /// /// 短信验证码类型 @@ -34,5 +34,10 @@ /// [通过手机号码]登录 /// Login = 205, + + /// + /// 绑定手机号码 + /// + BindPhoneNumber = 206, } } \ No newline at end of file