-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C端用户 #63
base: main
Are you sure you want to change the base?
Conversation
…hirdPartyProvider枚举;优化UserDeliveryAddress和UserThirdPartyLogin实体的内部方法实现
…ity Framework Core至9.0.0版本
…;优化代码格式和命名空间引用;移除冗余代码
…UserLoginHistory实体及相关命令处理逻辑;优化代码结构
if (PasswordHash != passwordHash) | ||
{ | ||
PasswordFailedTimes++; | ||
throw new KnownException("用户名或密码错误"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里如果throw 的话, PasswordFailedTimes就不会被保存了
{ | ||
builder.ToTable("clientUsers"); | ||
builder.HasKey(cu => cu.Id); | ||
builder.Property(cu => cu.Id).ValueGeneratedOnAdd().UseSnowFlakeValueGenerator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValueGeneratedOnAdd 是不需要的
{ | ||
builder.ToTable("clientUserLoginHistory"); | ||
builder.HasKey(a => a.Id); | ||
builder.Property(a => a.Id).ValueGeneratedOnAdd().UseSnowFlakeValueGenerator(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValueGeneratedOnAdd 是不需要的
{ | ||
RuleFor(x => x.NickName).NotEmpty().WithMessage("昵称不能为空"); | ||
RuleFor(x => x.Phone).NotEmpty().WithMessage("手机号不能为空"); | ||
RuleFor(x => x.PasswordHash).NotEmpty().WithMessage("密码不能为空"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
缺少手机号是否重复的验证
request.PasswordHash, | ||
request.PasswordSalt, | ||
request.Email); | ||
clientUserRepository.Add(user); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
请使用 await AddAsync 异步API
request.UserAgent | ||
)); | ||
|
||
var token = tokenGenerator.GenerateJwtAsync([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
jwt的功能,可以使用框架提供的jwt私钥存储和token生成功能
} | ||
|
||
[HttpPut] | ||
public async Task<ResponseData> Disable([FromBody] ClientUserDisableRequest request) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c端用户禁用启用应该是admin后台的功能
public async Task<ResponseData> AddDeliveryAddress([FromBody] AddDeliveryAddressRequest request) | ||
{ | ||
return await mediator.Send(new ClientUserAddDeliveryAddressCommand( | ||
request.UserId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
c端用户的操作的命令中,userid 应该从当前登录身份中获取,否则会出现权限泄露的可能性,a用户可以修改b用户的数据
public async Task<ResponseData> RemoveDeliveryAddress([FromQuery] RemoveDeliveryAddressRequest request) | ||
{ | ||
return await mediator.Send(new ClientUserRemoveDeliveryAddressCommand( | ||
request.UserId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
userid 应该从当前登录token中获取
|
||
namespace NetCorePal.D3Shop.Web.Helper; | ||
|
||
public class TokenGenerator(IOptions<AppConfiguration> appConfiguration) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…结果;调整登录方法返回类型,改进错误处理和响应结构
No description provided.