Skip to content
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

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open

C端用户 #63

wants to merge 16 commits into from

Conversation

Zzzzjle
Copy link
Member

@Zzzzjle Zzzzjle commented Feb 22, 2025

No description provided.

@Zzzzjle Zzzzjle changed the title WIP:C端用户 C端用户 Mar 3, 2025
if (PasswordHash != passwordHash)
{
PasswordFailedTimes++;
throw new KnownException("用户名或密码错误");
Copy link
Member

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();
Copy link
Member

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();
Copy link
Member

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("密码不能为空");
Copy link
Member

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);
Copy link
Member

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([
Copy link
Member

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)
Copy link
Member

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,
Copy link
Member

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,
Copy link
Member

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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants