Repository navigation
新增邮箱验证码登录(email_code)支持 - #1488
Merged
Merged
Conversation
MayueCif
commented
Oct 12, 2026
Contributor
- 新增缓存 key 常量 EMAIL_LOGIN_CODE_PRE、EMAIL_LOGIN_SEND_PRE,并在 CacheKey 中添加 EmailCodeLoginKey、EmailCodeLoginSendKey 生成方法。
- EmailAgent 支持 SendEmailTypes.Login,使用新增的发送 key 与 value key。
- 在 CommandHandler 的发送邮件前置校验中将 SendEmailTypes.Login 纳入需存在用户的分支。
- 新增 LoginByEmailCommand 与 LoginByEmailCommandValidator(校验 Email 与 Code)。
- 在 CommandHandler 中新增 LoginByEmailAsync:根据邮箱加载用户(含角色与 Staff)、调用 VerifyEmailCodeAsync 校验并移除缓存 key,校验失败抛出 INVALID_EMAIL_CAPTCHA,校验通过返回由 UserDomainService 拼装的用户详情到 command.Result。
- UserService 新增匿名接口 PostLoginByEmailAsync,发布 LoginByEmailCommand 并返回登录用户模型。
- 新增 IdentityServer 扩展 grant 验证器 EmailCodeGrantValidator(GrantType="email_code"),从请求读取 Email/Code 调用远端 UserService.LoginByEmailAsync,成功设置 GrantValidationResult 并记录日志,失败返回 InvalidGrant。
- 在 Program.cs 的 IdentityServer 注册链中加入 .AddExtensionGrantValidator(),启用 email_code 扩展登录方式。
- 新增缓存 key 常量 EMAIL_LOGIN_CODE_PRE、EMAIL_LOGIN_SEND_PRE,并在 CacheKey 中添加 EmailCodeLoginKey、EmailCodeLoginSendKey 生成方法。 - EmailAgent 支持 SendEmailTypes.Login,使用新增的发送 key 与 value key。 - 在 CommandHandler 的发送邮件前置校验中将 SendEmailTypes.Login 纳入需存在用户的分支。 - 新增 LoginByEmailCommand 与 LoginByEmailCommandValidator(校验 Email 与 Code)。 - 在 CommandHandler 中新增 LoginByEmailAsync:根据邮箱加载用户(含角色与 Staff)、调用 VerifyEmailCodeAsync 校验并移除缓存 key,校验失败抛出 INVALID_EMAIL_CAPTCHA,校验通过返回由 UserDomainService 拼装的用户详情到 command.Result。 - UserService 新增匿名接口 PostLoginByEmailAsync,发布 LoginByEmailCommand 并返回登录用户模型。 - 新增 IdentityServer 扩展 grant 验证器 EmailCodeGrantValidator(GrantType="email_code"),从请求读取 Email/Code 调用远端 UserService.LoginByEmailAsync,成功设置 GrantValidationResult 并记录日志,失败返回 InvalidGrant。 - 在 Program.cs 的 IdentityServer 注册链中加入 .AddExtensionGrantValidator<EmailCodeGrantValidator>(),启用 email_code 扩展登录方式。
|
Qinyouzeng
approved these changes
Oct 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


