绑定手机 & 解绑快速登录

This commit is contained in:
Aigio Liu
2021-05-12 20:16:16 +08:00
parent 0923e5ad3e
commit 316d514b9b
8 changed files with 154 additions and 2 deletions
+1
View File
@@ -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)
+1
View File
@@ -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)
@@ -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
{
/// <summary>
/// 短信验证码
/// </summary>
[MPKey(0)]
[N_JsonProperty("0")]
[S_JsonProperty("0")]
public string? SmsCode { get; set; }
/// <summary>
/// 手机号码
/// </summary>
[MPKey(1)]
[N_JsonProperty("1")]
[S_JsonProperty("1")]
public string? PhoneNumber { get; set; }
}
}
@@ -43,5 +43,19 @@ namespace System.Application.Services.CloudService.Clients.Abstractions
/// </summary>
/// <returns></returns>
Task<IApiResponse> SignOut();
/// <summary>
/// 绑定手机号码(通过快速登录注册的账号需要此功能)
/// </summary>
/// <param name="request"></param>
/// <returns></returns>
Task<IApiResponse> BindPhoneNumber(BindPhoneNumberRequest request);
/// <summary>
/// 解绑账号
/// </summary>
/// <param name="channel"></param>
/// <returns></returns>
Task<IApiResponse> UnbundleAccount(FastLoginChannel channel);
}
}
@@ -33,7 +33,7 @@ namespace System.Application.Services.CloudService.Clients
public Task<IApiResponse> 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<IApiResponse> BindPhoneNumber(BindPhoneNumberRequest request)
=> conn.SendAsync(
isAnonymous: false,
isSecurity: true,
method: HttpMethod.Post,
requestUri: "api/Manage/BindPhoneNumber",
request: request,
cancellationToken: default);
public Task<IApiResponse> UnbundleAccount(FastLoginChannel channel)
=> conn.SendAsync(
isAnonymous: false,
method: HttpMethod.Delete,
requestUri: $"api/Manage/UnbundleAccount/{(int)channel}",
cancellationToken: default);
}
}
@@ -93,6 +93,20 @@ namespace System.Application.Services.CloudService
}
}
public async Task<IApiResponse> 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<IApiResponse<AppVersionDTO?>> CheckUpdate(Guid id, Platform platform, DeviceIdiom deviceIdiom, ArchitectureFlags supportedAbis, Version osVersion, ArchitectureFlags abi)
{
return Task.FromResult(ApiResponse.Ok<AppVersionDTO?>(default));
+73
View File
@@ -0,0 +1,73 @@
namespace System.Application
{
/// <summary>
/// 快速登录渠道
/// </summary>
public enum FastLoginChannel
{
/// <summary>
/// https://www.nuget.org/packages/AspNet.Security.OpenId.Steam
/// </summary>
Steam,
/// <summary>
/// https://www.nuget.org/packages/Microsoft.AspNetCore.Authentication.MicrosoftAccount
/// </summary>
Microsoft,
/// <summary>
/// https://www.nuget.org/packages/AspNet.Security.OAuth.QQ
/// </summary>
QQ,
/// <summary>
/// https://www.nuget.org/packages/AspNet.Security.OAuth.Apple
/// </summary>
Apple,
///// <summary>
///// https://www.nuget.org/packages/AspNet.Security.OAuth.Weixin
///// </summary>
//Weixin,
///// <summary>
///// https://www.nuget.org/packages/AspNet.Security.OAuth.Weibo
///// </summary>
//Weibo,
///// <summary>
///// https://www.nuget.org/packages/AspNet.Security.OAuth.BattleNet
///// </summary>
//BattleNet,
///// <summary>
///// https://www.nuget.org/packages/AspNet.Security.OAuth.NetEase
///// </summary>
//NetEase,
///// <summary>
///// https://www.nuget.org/packages/AspNet.Security.OAuth.LinkedIn
///// </summary>
//LinkedIn,
///// <summary>
///// https://www.nuget.org/packages/AspNet.Security.OAuth.GitHub
///// </summary>
//GitHub,
///// <summary>
///// https://www.nuget.org/packages/AspNet.Security.OAuth.Discord
///// </summary>
//Discord,
///// <summary>
///// https://www.nuget.org/packages/AspNet.Security.OAuth.Baidu
///// </summary>
//Baidu,
///// <summary>
///// https://www.nuget.org/packages/AspNet.Security.OAuth.Gitee
///// </summary>
//Gitee,
}
}
+6 -1
View File
@@ -1,4 +1,4 @@
namespace System.Application
namespace System.Application
{
/// <summary>
/// 短信验证码类型
@@ -34,5 +34,10 @@
/// [通过手机号码]登录
/// </summary>
Login = 205,
/// <summary>
/// 绑定手机号码
/// </summary>
BindPhoneNumber = 206,
}
}