[缺陷] CLA的修改企业超级管理员存在缺陷-的开发实现-app-cla-server部分#505
Open
fly333sky wants to merge 1 commit into
Open
Conversation
Contributor
|
Caution The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased. |
Welcome To opensourceways CommunityHey @fly333sky , thanks for your contribution to the community. Bot Usage ManualI'm the Bot here serving you. You can find the instructions on how to interact with me at Here . That means you can comment below every pull request or issue to trigger Bot Commands. Contact GuideIf you have any questions, please contact the SIG: infratructure , |
CLA Signature Passfly333sky, thanks for your pull request. All authors of the commits have signed the CLA. 👍 |
|
|||||||||||||||
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.
背景
[缺陷] CLA的修改企业超级管理员存在缺陷(app-cla-server)· 开发流水线 · 开发预览阶段(代码已推 + 预览已部署 + UT 已补;门禁/对抗由 PR CI 异步跑)
改动内容
fix(app-cla-server): 修改企业超级管理员时为新管理员补建账号,保证可登录
修复 issue #1479:社区管理员「修改企业超级管理员」后,若新管理员邮箱此前未预置
user 账号,旧逻辑只调用
userService.UpdateEmail(按旧邮箱查找),查不到就报错,导致新管理员无法重置密码、无法登录。
改动内容
改造
UpdateRepresentative调用链(app→adapter→models→controllers),使其在
corp_signing持久化后按需同步 user 账号:signing/domain/userservice/service.goUserService接口新增UpdateEmailByAccount(linkId, account, newEmail),用于「邮箱漂移的孤儿管理员账号」回退分支:按 account 定位孤儿并把邮箱改写到
新邮箱(account 域与邮箱域一致,account 不变)。
signing/app/corp_signing.go(核心)UpdateRepresentative返回值由error调整为(*ManagerDTO, error)。cs.Admin.Id == ""或邮箱未变 → 跳过,返回nil;IsAValidUser真)→ 沿用UpdateEmail,返回nil;userService.Add新建账号,回填ManagerDTO(含初始口令),供上层发账号通知邮件;
Add因 account 重复失败(孤儿账号,ErrorCodeUserExists)→ 回退UpdateEmailByAccount改写邮箱,返回nil;Add其它错误 → 直接返回错误。logs.Info标注,便于运维识别历史脏数据修复。signing/adapter/corp_signing.go:透传created,映射为*models.CorporationManagerCreateOption(复用既有toCorporationManagerCreateOption)。models/init.go+models/corp_signing.go:corpSigningAdapter接口与UpdateCorpRepresentative返回值同步调整为(*CorporationManagerCreateOption, IModelError)。controllers/corp_signing.go:UpdateRepresentative成功且created != nil时,models.GetLink取orgInfo后notifyCorpAdmin发账号邮件(与AddCorpAdmin完全一致的邮件通知路径);
GetLink失败仅记 error 日志(更新已成功,best-effort)。需求对应
UpdateEmail分支;Add新建 + 邮件通知,修复前此用例失败;corp_signing.rep;UT(同 PR 补写)
signing/app/corp_signing_test.go+signing/app/main_test.go:覆盖UpdateRepresentative全部分支(账号存在同域/跨域、缺失新建、邮箱未变、管理员未创建、孤儿回退、Add 其它错误、权限不足、link_id 不匹配、Find/Update/IsAValidUser/UpdateEmail/
回退失败、参数非法),
UpdateRepresentative增量覆盖率 95.2%。signing/domain/userservice/service_test.go:覆盖UpdateEmailByAccount成功/账号不存在/Save 失败,覆盖率 100%。signing/adapter/corp_signing_test.go+signing/adapter/main_test.go:覆盖adapter 参数校验、
created==nil/created!=nil映射、服务层错误,覆盖率 100%。go build ./...通过;go test ./signing/app/... ./signing/domain/userservice/... ./signing/adapter/...全绿。(注:
signing/watch的TestNotifyAdminConfigSetDefault与models/individual_signing_test.go相关 Issue
resolve https://github.com/opensourceways/backlog/issues/1479
AI 使用声明
当前 PR 是否有 AI 参与:
/ai-develop-preview