Skip to content

Conversation

@jinronga
Copy link
Contributor

@jinronga jinronga commented Oct 20, 2024

Link to an issue

Optimize registration logic

What

How

Screenshots

How to test

Checklist

  • Link to an issue if it really related.
  • At least describe what this PR does.
  • Use rebase to confirm that current branch doesn't conflict with main branch.
  • Unit tests. At least do not reduce the unit test coverage.
  • Checked and updated guidelines.md which used to describe how to build, deploy and use DouTok.

@jinronga
Copy link
Contributor Author

邮箱+手机号 我想在数据库设计加个唯一索引,保证邮箱+手机号的唯一性

@jinronga
Copy link
Contributor Author

image
利用数据库的特性来设计,这样代码开发优雅点

token, err := a.setToken2Header(ctx, claims.New(userId))
if err != nil {
log.Context(ctx).Error("failed to generate token: %v", err)
return nil, errorx.New(1, "failed to generate token")
Copy link
Contributor

@TremblingV5 TremblingV5 Oct 20, 2024

Choose a reason for hiding this comment

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

这里如果可以建议改成只记录日志而不报错,与登录接口不一样,注册没有token并不代表注册失败,直接报错会导致前端无法识别注册操作到底是成功还是失败

或者是定义一个专门的错误码,由前端根据错误码来判断是否只是token生成失败

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的

Copy link
Contributor Author

Choose a reason for hiding this comment

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

项目状态码放在哪里呢 还是生成有异常token 直接返回空

Copy link
Contributor

Choose a reason for hiding this comment

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

我不太记得infrastructure目录下是否有定义状态码的位置,这个可以看着来,大不了以后再优化

@TremblingV5
Copy link
Contributor

邮箱+手机号 我想在数据库设计加个唯一索引,保证邮箱+手机号的唯一性

这里好像可以邮箱和手机号各自一个唯一索引,邮箱和手机号都应该是唯一的

另外还有一张account表,如果要加索引麻烦account表也处理掉,account相当于提供一个全局唯一账号的功能,user表的手机号和邮箱只是一份冗余,可以考虑不要

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