Browse Source
Merge pull request #1363 from colinin/aliyun-security-verify-code
feat(account): Alibaba Cloud SMS Security Code module
pull/1366/head
yx lin
5 months ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with
97 additions and
0 deletions
-
aspnet-core/modules/account/LINGYUN.Abp.Account.Security.Aliyun/FodyWeavers.xml
-
aspnet-core/modules/account/LINGYUN.Abp.Account.Security.Aliyun/FodyWeavers.xsd
-
aspnet-core/modules/account/LINGYUN.Abp.Account.Security.Aliyun/LINGYUN.Abp.Account.Security.Aliyun.csproj
-
aspnet-core/modules/account/LINGYUN.Abp.Account.Security.Aliyun/LINGYUN/Abp/Account/Security/Aliyun/AbpAccountSecurityAliyunModule.cs
-
aspnet-core/modules/account/LINGYUN.Abp.Account.Security.Aliyun/LINGYUN/Abp/Account/Security/Aliyun/AliyunAccountSmsSecurityCodeSender.cs
|
|
|
@ -0,0 +1,3 @@ |
|
|
|
<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd"> |
|
|
|
<ConfigureAwait ContinueOnCapturedContext="false" /> |
|
|
|
</Weavers> |
|
|
|
@ -0,0 +1,30 @@ |
|
|
|
<?xml version="1.0" encoding="utf-8"?> |
|
|
|
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"> |
|
|
|
<!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. --> |
|
|
|
<xs:element name="Weavers"> |
|
|
|
<xs:complexType> |
|
|
|
<xs:all> |
|
|
|
<xs:element name="ConfigureAwait" minOccurs="0" maxOccurs="1"> |
|
|
|
<xs:complexType> |
|
|
|
<xs:attribute name="ContinueOnCapturedContext" type="xs:boolean" /> |
|
|
|
</xs:complexType> |
|
|
|
</xs:element> |
|
|
|
</xs:all> |
|
|
|
<xs:attribute name="VerifyAssembly" type="xs:boolean"> |
|
|
|
<xs:annotation> |
|
|
|
<xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation> |
|
|
|
</xs:annotation> |
|
|
|
</xs:attribute> |
|
|
|
<xs:attribute name="VerifyIgnoreCodes" type="xs:string"> |
|
|
|
<xs:annotation> |
|
|
|
<xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation> |
|
|
|
</xs:annotation> |
|
|
|
</xs:attribute> |
|
|
|
<xs:attribute name="GenerateXsd" type="xs:boolean"> |
|
|
|
<xs:annotation> |
|
|
|
<xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation> |
|
|
|
</xs:annotation> |
|
|
|
</xs:attribute> |
|
|
|
</xs:complexType> |
|
|
|
</xs:element> |
|
|
|
</xs:schema> |
|
|
|
@ -0,0 +1,21 @@ |
|
|
|
<Project Sdk="Microsoft.NET.Sdk"> |
|
|
|
|
|
|
|
<Import Project="..\..\..\..\configureawait.props" /> |
|
|
|
<Import Project="..\..\..\..\common.props" /> |
|
|
|
|
|
|
|
<PropertyGroup> |
|
|
|
<TargetFrameworks>netstandard2.0;netstandard2.1;net8.0;net9.0</TargetFrameworks> |
|
|
|
<AssemblyName>LINGYUN.Abp.Account.Security.Aliyun</AssemblyName> |
|
|
|
<PackageId>LINGYUN.Abp.Account.Security.Aliyun</PackageId> |
|
|
|
<GenerateAssemblyConfigurationAttribute>false</GenerateAssemblyConfigurationAttribute> |
|
|
|
<GenerateAssemblyCompanyAttribute>false</GenerateAssemblyCompanyAttribute> |
|
|
|
<GenerateAssemblyProductAttribute>false</GenerateAssemblyProductAttribute> |
|
|
|
<RootNamespace /> |
|
|
|
</PropertyGroup> |
|
|
|
|
|
|
|
<ItemGroup> |
|
|
|
<ProjectReference Include="..\..\..\framework\common\LINGYUN.Abp.Sms.Aliyun\LINGYUN.Abp.Sms.Aliyun.csproj" /> |
|
|
|
<ProjectReference Include="..\LINGYUN.Abp.Account.Security\LINGYUN.Abp.Account.Security.csproj" /> |
|
|
|
</ItemGroup> |
|
|
|
|
|
|
|
</Project> |
|
|
|
@ -0,0 +1,11 @@ |
|
|
|
using LINGYUN.Abp.Sms.Aliyun; |
|
|
|
using Volo.Abp.Modularity; |
|
|
|
|
|
|
|
namespace LINGYUN.Abp.Account.Security.Aliyun; |
|
|
|
|
|
|
|
[DependsOn( |
|
|
|
typeof(AbpAccountSecurityModule), |
|
|
|
typeof(AbpAliyunSmsModule))] |
|
|
|
public class AbpAccountSecurityAliyunModule : AbpModule |
|
|
|
{ |
|
|
|
} |
|
|
|
@ -0,0 +1,32 @@ |
|
|
|
using LINGYUN.Abp.Sms.Aliyun; |
|
|
|
using Microsoft.Extensions.DependencyInjection; |
|
|
|
using System.Threading; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Volo.Abp.DependencyInjection; |
|
|
|
|
|
|
|
namespace LINGYUN.Abp.Account.Security.Aliyun; |
|
|
|
|
|
|
|
[Dependency(ServiceLifetime.Transient, ReplaceServices = true)] |
|
|
|
[ExposeServices(typeof(IAccountSmsSecurityCodeSender), typeof(AliyunAccountSmsSecurityCodeSender))] |
|
|
|
public class AliyunAccountSmsSecurityCodeSender : IAccountSmsSecurityCodeSender |
|
|
|
{ |
|
|
|
protected IAliyunSmsVerifyCodeSender SmsVerifyCodeSender { get; } |
|
|
|
public AliyunAccountSmsSecurityCodeSender( |
|
|
|
IAliyunSmsVerifyCodeSender smsVerifyCodeSender) |
|
|
|
{ |
|
|
|
SmsVerifyCodeSender = smsVerifyCodeSender; |
|
|
|
} |
|
|
|
|
|
|
|
public async virtual Task SendAsync( |
|
|
|
string phone, |
|
|
|
string code, |
|
|
|
string templateCode, |
|
|
|
CancellationToken cancellation = default) |
|
|
|
{ |
|
|
|
// TODO: 传递验证码有效期
|
|
|
|
await SmsVerifyCodeSender.SendAsync( |
|
|
|
new SmsVerifyCodeMessage(phone, |
|
|
|
new SmsVerifyCodeMessageParam(code, "5"), |
|
|
|
templateCode: templateCode)); |
|
|
|
} |
|
|
|
} |