mirror of
https://github.com/nsnail/NetAdmin.git
synced 2025-04-22 22:22:51 +08:00
parent
b01b8b24ba
commit
5edcf63e24
@ -70,13 +70,13 @@
|
|||||||
等于
|
等于
|
||||||
等待发送
|
等待发送
|
||||||
系统模块
|
系统模块
|
||||||
绑定手机号
|
绑定手机号码
|
||||||
结果非预期
|
结果非预期
|
||||||
群众
|
群众
|
||||||
自定义
|
自定义
|
||||||
范围
|
范围
|
||||||
菜单
|
菜单
|
||||||
解绑手机号
|
解绑手机号码
|
||||||
警告
|
警告
|
||||||
调试
|
调试
|
||||||
跟踪
|
跟踪
|
||||||
|
@ -58,7 +58,7 @@ XML注释文件不存在
|
|||||||
父节点不存在
|
父节点不存在
|
||||||
用户不存在
|
用户不存在
|
||||||
用户名不能为空
|
用户名不能为空
|
||||||
用户名不能是手机号
|
用户名不能是手机号码
|
||||||
用户名或密码错误
|
用户名或密码错误
|
||||||
用户名长度4位以上
|
用户名长度4位以上
|
||||||
用户头像不能为空
|
用户头像不能为空
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
namespace NetAdmin.Domain.Attributes.DataValidation;
|
namespace NetAdmin.Domain.Attributes.DataValidation;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 手机号验证器
|
/// 手机号码验证器
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter)]
|
[AttributeUsage(AttributeTargets.Field | AttributeTargets.Property | AttributeTargets.Parameter)]
|
||||||
public sealed class MobileAttribute : RegexAttribute
|
public sealed class MobileAttribute : RegexAttribute
|
||||||
@ -12,7 +12,7 @@ public sealed class MobileAttribute : RegexAttribute
|
|||||||
public MobileAttribute() //
|
public MobileAttribute() //
|
||||||
: base(Chars.RGX_MOBILE)
|
: base(Chars.RGX_MOBILE)
|
||||||
{
|
{
|
||||||
ErrorMessageResourceName = nameof(Ln.手机号不正确);
|
ErrorMessageResourceName = nameof(Ln.手机号码不正确);
|
||||||
ErrorMessageResourceType = typeof(Ln);
|
ErrorMessageResourceType = typeof(Ln);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -27,8 +27,8 @@ public sealed class UserNameAttribute : RegexAttribute
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 不能是手机号
|
// 不能是手机号码
|
||||||
ErrorMessageResourceName = nameof(Ln.用户名不能是手机号);
|
ErrorMessageResourceName = nameof(Ln.用户名不能是手机号码);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -49,7 +49,7 @@ public record Sys_User : VersionEntity, IFieldSummary, IFieldEnabled, IRegister
|
|||||||
public virtual bool Enabled { get; init; }
|
public virtual bool Enabled { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 手机号
|
/// 手机号码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_15)]
|
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_15)]
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
|
@ -80,7 +80,7 @@ public record Sys_UserProfile : VersionEntity, IRegister
|
|||||||
public int? EmergencyContactArea { get; init; }
|
public int? EmergencyContactArea { get; init; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 紧急联系人手机号
|
/// 紧急联系人手机号码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_15)]
|
[Column(DbType = Chars.FLG_DB_FIELD_TYPE_VARCHAR_15)]
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
|
@ -4,13 +4,13 @@ using NetAdmin.Domain.DbMaps.Sys;
|
|||||||
namespace NetAdmin.Domain.Dto.Sys.User;
|
namespace NetAdmin.Domain.Dto.Sys.User;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求:检查手机号是否可用
|
/// 请求:检查手机号码是否可用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed record CheckMobileAvailableReq : Sys_User
|
public sealed record CheckMobileAvailableReq : Sys_User
|
||||||
{
|
{
|
||||||
/// <inheritdoc cref="Sys_User.Mobile" />
|
/// <inheritdoc cref="Sys_User.Mobile" />
|
||||||
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
||||||
[Mobile]
|
[Mobile]
|
||||||
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.手机号不能为空))]
|
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.手机号码不能为空))]
|
||||||
public override string Mobile { get; init; }
|
public override string Mobile { get; init; }
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ namespace NetAdmin.Domain.Dto.Sys.User;
|
|||||||
public sealed record LoginByPwdReq : DataAbstraction
|
public sealed record LoginByPwdReq : DataAbstraction
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 用户名、手机号、邮箱
|
/// 用户名、手机号码、邮箱
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.账号不能为空))]
|
[Required(ErrorMessageResourceType = typeof(Ln), ErrorMessageResourceName = nameof(Ln.账号不能为空))]
|
||||||
public string Account { get; init; }
|
public string Account { get; init; }
|
||||||
|
@ -3,7 +3,7 @@ using NetAdmin.Domain.Dto.Sys.VerifyCode;
|
|||||||
namespace NetAdmin.Domain.Dto.Sys.User;
|
namespace NetAdmin.Domain.Dto.Sys.User;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 请求:设置手机号
|
/// 请求:设置手机号码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public sealed record SetMobileReq : DataAbstraction
|
public sealed record SetMobileReq : DataAbstraction
|
||||||
{
|
{
|
||||||
|
@ -7,9 +7,9 @@ namespace NetAdmin.Domain.Enums.Sys;
|
|||||||
public enum VerifyCodeTypes
|
public enum VerifyCodeTypes
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 绑定手机号
|
/// 绑定手机号码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ResourceDescription<Ln>(nameof(Ln.绑定手机号))]
|
[ResourceDescription<Ln>(nameof(Ln.绑定手机号码))]
|
||||||
LinkMobile = 1
|
LinkMobile = 1
|
||||||
|
|
||||||
,
|
,
|
||||||
@ -23,9 +23,9 @@ public enum VerifyCodeTypes
|
|||||||
,
|
,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 解绑手机号
|
/// 解绑手机号码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[ResourceDescription<Ln>(nameof(Ln.解绑手机号))]
|
[ResourceDescription<Ln>(nameof(Ln.解绑手机号码))]
|
||||||
UnlinkMobile = 3
|
UnlinkMobile = 3
|
||||||
|
|
||||||
,
|
,
|
||||||
|
@ -15,7 +15,7 @@ public interface IUserModule : ICrudModule<CreateUserReq, QueryUserRsp // 创建
|
|||||||
>
|
>
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查手机号是否可用
|
/// 检查手机号码是否可用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<bool> CheckMobileAvailableAsync(CheckMobileAvailableReq req);
|
Task<bool> CheckMobileAvailableAsync(CheckMobileAvailableReq req);
|
||||||
|
|
||||||
@ -65,7 +65,7 @@ public interface IUserModule : ICrudModule<CreateUserReq, QueryUserRsp // 创建
|
|||||||
Task SetEnabledAsync(SetUserEnabledReq req);
|
Task SetEnabledAsync(SetUserEnabledReq req);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置手机号
|
/// 设置手机号码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
Task<UserInfoRsp> SetMobileAsync(SetMobileReq req);
|
Task<UserInfoRsp> SetMobileAsync(SetMobileReq req);
|
||||||
|
|
||||||
|
@ -284,14 +284,14 @@ public sealed class UserService(
|
|||||||
.ToOneAsync(a => new { a.Mobile, a.Version, a.Email })
|
.ToOneAsync(a => new { a.Mobile, a.Version, a.Email })
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
// 如果已绑定手机号、需要手机安全验证
|
// 如果已绑定手机号码、需要手机安全验证
|
||||||
if (!user.Mobile.NullOrEmpty()) {
|
if (!user.Mobile.NullOrEmpty()) {
|
||||||
if (!await verifyCodeService.VerifyAsync(req.VerifySmsCodeReq).ConfigureAwait(false)) {
|
if (!await verifyCodeService.VerifyAsync(req.VerifySmsCodeReq).ConfigureAwait(false)) {
|
||||||
throw new NetAdminInvalidOperationException(Ln.验证码不正确);
|
throw new NetAdminInvalidOperationException(Ln.验证码不正确);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Mobile != req.VerifySmsCodeReq.DestDevice) {
|
if (user.Mobile != req.VerifySmsCodeReq.DestDevice) {
|
||||||
throw new NetAdminInvalidOperationException($"{Ln.手机号不正确}");
|
throw new NetAdminInvalidOperationException($"{Ln.手机号码不正确}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -328,19 +328,19 @@ public sealed class UserService(
|
|||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
|
||||||
if (!user.Mobile.NullOrEmpty()) {
|
if (!user.Mobile.NullOrEmpty()) {
|
||||||
// 已有手机号,需验证旧手机
|
// 已有手机号码,需验证旧手机
|
||||||
if (!await verifyCodeService.VerifyAsync(req.OriginVerifySmsCodeReq).ConfigureAwait(false)) {
|
if (!await verifyCodeService.VerifyAsync(req.OriginVerifySmsCodeReq).ConfigureAwait(false)) {
|
||||||
throw new NetAdminInvalidOperationException($"{Ln.旧手机号验证码不正确}");
|
throw new NetAdminInvalidOperationException($"{Ln.旧手机号码验证码不正确}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (user.Mobile != req.OriginVerifySmsCodeReq.DestDevice) {
|
if (user.Mobile != req.OriginVerifySmsCodeReq.DestDevice) {
|
||||||
throw new NetAdminInvalidOperationException($"{Ln.旧手机号不正确}");
|
throw new NetAdminInvalidOperationException($"{Ln.旧手机号码不正确}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 验证新手机号
|
// 验证新手机号码
|
||||||
if (!await verifyCodeService.VerifyAsync(req.NewVerifySmsCodeReq).ConfigureAwait(false)) {
|
if (!await verifyCodeService.VerifyAsync(req.NewVerifySmsCodeReq).ConfigureAwait(false)) {
|
||||||
throw new NetAdminInvalidOperationException($"{Ln.新手机号验证码不正确}");
|
throw new NetAdminInvalidOperationException($"{Ln.新手机号码验证码不正确}");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (await Rpo.UpdateDiy
|
if (await Rpo.UpdateDiy
|
||||||
|
@ -27,7 +27,7 @@ public sealed class UserController(IUserCache cache, IConfigCache configCache)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 检查手机号是否可用
|
/// 检查手机号码是否可用
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
public Task<bool> CheckMobileAvailableAsync(CheckMobileAvailableReq req)
|
public Task<bool> CheckMobileAvailableAsync(CheckMobileAvailableReq req)
|
||||||
@ -192,7 +192,7 @@ public sealed class UserController(IUserCache cache, IConfigCache configCache)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 设置手机号
|
/// 设置手机号码
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Transaction]
|
[Transaction]
|
||||||
public Task<UserInfoRsp> SetMobileAsync(SetMobileReq req)
|
public Task<UserInfoRsp> SetMobileAsync(SetMobileReq req)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user