Skip to content

fix(auth): 添加密码登录注册功能开关控制 - #2787

Closed
lanfunoe wants to merge 5048 commits into
QuantumNous:mainfrom
lanfunoe:fix/register-username-option-when-password-disabled
Closed

fix(auth): 添加密码登录注册功能开关控制#2787
lanfunoe wants to merge 5048 commits into
QuantumNous:mainfrom
lanfunoe:fix/register-username-option-when-password-disabled

Conversation

@lanfunoe

@lanfunoe lanfunoe commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

fix #2719

  • 在 misc controller 中添加 password_login 和 password_register 配置项
  • 为 LoginForm 组件添加密码登录按钮的条件渲染
  • 为 RegisterForm 组件添加密码注册按钮的条件渲染
  • 根据系统配置动态显示或隐藏相应的登录注册选项

Summary by CodeRabbit

  • New Features

    • Email/password login and registration UI now show or hide based on system configuration (password login/register flags).
  • Bug Fixes

    • Minor UI alignment adjustment for improved visual consistency.

✏️ Tip: You can customize this high-level summary in your review settings.

Calcium-Ion and others added 30 commits December 9, 2025 14:04
fix: Try to fix login error "already logged in" issue
fix: Use channel proxy settings for task query scenarios
feat: add openai video remix endpoint
- Adjust sender field format, add space to separate nickname and email address
- Ensure email header format complies with standard RFC specifications
- Fix potential email client sending exceptions (Tencent Cloud)
* fix: 支持aws 通过全局参数透传或者渠道参数透传来 调用

* fix(aws): replace json.Unmarshal with common.Unmarshal for request body processing

---------

Co-authored-by: r0 <liangchunlei@01.ai>
Co-authored-by: CaIon <i@caion.me>
…group-retry

feat(token): add cross-group retry option for token processing
feat(adaptor): add '-xhigh' suffix to reasoning effort options
…retry

fix(channel_select): adjust priority retry logic for cross-group
…-tts

feat: support gpt tts series model quota calculate
seefs001 and others added 19 commits January 26, 2026 19:56
* fix: test using the correct path for rerank.

* fix: The `input` parameter for testing responses uses an array to accommodate certain channels, such as Codex, which are incompatible with single strings.
* feat: channel affinity

* feat: channel affinity -> model setting

* fix: channel affinity

* feat: channel affinity op

* feat: channel_type setting

* feat: clean

* feat: cache supports both memory and Redis.

* feat: Optimise ui/ux

* feat: Optimise ui/ux

* feat: Optimise codex usage ui/ux

* feat: Optimise ui/ux

* feat: Optimise ui/ux

* feat: Optimise ui/ux

* feat: If the affinitized channel fails and a retry succeeds on another channel, update the affinity to the successful channel
* feat: openai response /v1/response/compact

* feat: /v1/response/compact bill

* feat: /v1/response/compact

* feat: /v1/responses/compact -> codex channel

* feat: /v1/responses/compact -> codex channel

* feat: /v1/responses/compact -> codex channel

* feat: codex channel default models

* feat: compact model price

* feat: /v1/responses/comapct test
* feat: grok Usage Guidelines Violation Fee ui setting

* feat: grok Usage Guidelines Violation Fee consume log

* fix: grok Usage Guidelines Violation Fee log detail
Updated the reporting method for security issues to include a link to the draft security advisory.
feat(gemini): map OpenAI stop to Gemini stopSequences
fix: remove disable_parallel_tool_use if tool_choice=none
…t-price

fix: /v1/responses/compact default billing
* feat: 引入通用 HTTP BodyStorage/DiskCache 缓存配置与管理

- 新增 common/body_storage.go 提供 HTTP 请求体存储抽象和文件缓存能力
- 增加 common/disk_cache_config.go 支持全局磁盘缓存配置
- main.go 挂载缓存初始化流程
- 新增和补充 controller/performance.go (及 unix/windows) 用于缓存性能监控接口
- middleware/body_cleanup.go 自动清理缓存文件
- router 挂载相关接口
- 前端 settings 页面新增性能监控设置 PerformanceSetting
- 优化缓存开关状态和模块热插拔能力
- 其他相关文件同步适配缓存扩展

* fix: 修复 BodyStorage 并发安全和错误处理问题

- 修复 diskStorage.Close() 竞态条件,先获取锁再执行 CAS
- 为 memoryStorage 添加互斥锁和 closed 状态检查
- 修复 CreateBodyStorageFromReader 在磁盘存储失败时的回退逻辑
- 添加缓存命中统计调用 (IncrementDiskCacheHits/IncrementMemoryCacheHits)
- 修复 gin.go 中 Seek 错误被忽略的问题
- 在 api-router 添加 BodyStorageCleanup 中间件
- 修复前端 formatBytes 对异常值的处理

Co-authored-by: Cursor <cursoragent@cursor.com>

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
- 在 misc controller 中添加 password_login 和 password_register 配置项
- 为 LoginForm 组件添加密码登录按钮的条件渲染
- 为 RegisterForm 组件添加密码注册按钮的条件渲染
- 根据系统配置动态显示或隐藏相应的登录注册选项
@coderabbitai

coderabbitai Bot commented Jan 30, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

Backend adds two boolean status flags: password_login and password_register. Frontend LoginForm and RegisterForm now conditionally render email/password login and registration UI based on those flags.

Changes

Cohort / File(s) Summary
Backend Status Endpoint
controller/misc.go
Added password_login and password_register fields to the GetStatus output, mapped from backend config flags.
Frontend Login UI
web/src/components/auth/LoginForm.jsx
Guarded rendering of the Divider and email/username login Button behind status.password_login.
Frontend Register UI
web/src/components/auth/RegisterForm.jsx
Guarded rendering of the Divider and email/username registration Button behind status.password_register.

Sequence Diagram(s)

sequenceDiagram
    participant Browser
    participant Frontend as WebApp
    participant Backend
    Browser->>Frontend: Load login/register page
    Frontend->>Backend: GET /status
    Backend-->>Frontend: { ..., password_login: bool, password_register: bool }
    Frontend->>Browser: Render UI
    alt password_login true
        Frontend->>Browser: Show email/password login controls
    else
        Frontend->>Browser: Hide email/password login controls
    end
    alt password_register true
        Frontend->>Browser: Show email/password registration controls
    else
        Frontend->>Browser: Hide email/password registration controls
    end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested labels

Ready to merge

Poem

🐇
Server whispers which doors can swing,
Flags that tell the login thing,
Buttons hide and buttons show,
I hop where toggles let me go,
Tiny paws applaud the spring.

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: adding feature toggles for password login and registration functionality across the auth system.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@lanfunoe lanfunoe changed the title feat(auth): 添加密码登录注册功能开关控制 fix(auth): 添加密码登录注册功能开关控制 Jan 30, 2026
- 在 LoginForm 中添加对 password_login 状态的条件渲染控制
- 在 RegisterForm 中添加对 password_register 状态的条件渲染控制
- 确保 Divider 组件只在相应功能启用时显示
- 保持按钮和其他组件的条件渲染逻辑一致性

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/src/components/auth/RegisterForm.jsx (1)

751-761: ⚠️ Potential issue | 🟡 Minor

Edge case: email form renders even when password_register is disabled and no OAuth providers exist.

When all OAuth providers are disabled, the fallback condition displays renderEmailRegisterForm() regardless of the password_register flag. The form will render but users cannot submit it (no backend check needed—the UX is broken). The same issue exists in LoginForm.jsx.

Add status.password_register to the fallback condition to prevent the form from displaying when the feature is disabled:

Suggested fix
         {showEmailRegister ||
-        !(
+        (!(
           status.github_oauth ||
           status.discord_oauth ||
           status.oidc_enabled ||
           status.wechat_login ||
           status.linuxdo_oauth ||
           status.telegram_oauth
-        )
+        ) && status.password_register)
           ? renderEmailRegisterForm()
           : renderOAuthOptions()}

Apply the same fix to LoginForm.jsx (add status.password_login to the condition).

🧹 Nitpick comments (1)
web/src/components/auth/RegisterForm.jsx (1)

481-498: Consider combining the two adjacent conditionals.

The logic correctly gates the Divider and registration button on status.password_register. Since both blocks share the same condition, they could be combined into a single fragment to reduce duplication.

♻️ Optional: Combine conditionals into a single fragment
-                {status.password_register && (
-                  <Divider margin='12px' align='center'>
-                    {t('或')}
-                  </Divider>
-                )}
-
-                {status.password_register && (
+                {status.password_register && (
+                  <>
+                    <Divider margin='12px' align='center'>
+                      {t('或')}
+                    </Divider>
                   <Button
                     theme='solid'
                     type='primary'
                     className='w-full h-12 flex items-center justify-center bg-black text-white !rounded-full hover:bg-gray-800 transition-colors'
                     icon={<IconMail size='large' />}
                     onClick={handleEmailRegisterClick}
                     loading={emailRegisterLoading}
                   >
                     <span className='ml-3'>{t('使用 用户名 注册')}</span>
                   </Button>
+                  </>
                 )}

- 添加了 hasShownRegisterDisabledError ref 来避免重复显示错误消息
- 实现了检查所有注册选项是否都被禁用的逻辑
- 当所有注册选项关闭时显示"管理员关闭了新用户注册"错误提示
- 修复了密码注册按钮显示条件,确保只有在密码注册启用时才显示
- 在登录和注册表单中将条件渲染改为 Fragment 包装以优化 JSX 结构

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@web/src/components/auth/LoginForm.jsx`:
- Around line 581-597: The email/password form is still rendered even when
status.password_login is false; update the LoginForm component to only
call/render renderEmailLoginForm() when status.password_login is true (same
check used for the Button block). Locate the renderEmailLoginForm invocation
inside LoginForm.jsx and wrap or gate it with a condition that checks
status.password_login (e.g., if (status.password_login) return
renderEmailLoginForm()), ensuring both the button and the full email/password
form follow the same flag.

Comment on lines +581 to +597
{status.password_login && (
<>
<Divider margin='12px' align='center'>
{t('或')}
</Divider>
<Button
theme='solid'
type='primary'
className='w-full h-12 flex items-center justify-center bg-black text-white !rounded-full hover:bg-gray-800 transition-colors'
icon={<IconMail size='large' />}
onClick={handleEmailLoginClick}
loading={emailLoginLoading}
>
<span className='ml-3'>{t('使用 邮箱或用户名 登录')}</span>
</Button>
</>
)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Password login can still be accessed when password_login is disabled.

This button is hidden, but the main render still shows the email/password form when no OAuth options exist, bypassing the flag. Gate renderEmailLoginForm() on status.password_login to enforce the config.

🔧 Suggested fix
-        {showEmailLogin ||
-        !(
-          status.github_oauth ||
-          status.discord_oauth ||
-          status.oidc_enabled ||
-          status.wechat_login ||
-          status.linuxdo_oauth ||
-          status.telegram_oauth
-        )
-          ? renderEmailLoginForm()
-          : renderOAuthOptions()}
+        {status.password_login &&
+        (showEmailLogin ||
+          !(
+            status.github_oauth ||
+            status.discord_oauth ||
+            status.oidc_enabled ||
+            status.wechat_login ||
+            status.linuxdo_oauth ||
+            status.telegram_oauth
+          ))
+          ? renderEmailLoginForm()
+          : renderOAuthOptions()}
🤖 Prompt for AI Agents
In `@web/src/components/auth/LoginForm.jsx` around lines 581 - 597, The
email/password form is still rendered even when status.password_login is false;
update the LoginForm component to only call/render renderEmailLoginForm() when
status.password_login is true (same check used for the Button block). Locate the
renderEmailLoginForm invocation inside LoginForm.jsx and wrap or gate it with a
condition that checks status.password_login (e.g., if (status.password_login)
return renderEmailLoginForm()), ensuring both the button and the full
email/password form follow the same flag.

- 将条件渲染中的重复代码块包装在Fragment中
- 统一登录表单中邮箱登录按钮的结构
- 统一注册表单中邮箱注册按钮的结构
- 移除多余的空行以改善代码可读性
- 保持现有功能不变的同时简化组件渲染逻辑
…n-password-disabled' into fix/register-username-option-when-password-disabled
- 移除未使用的 hasShownRegisterDisabledError 引用变量
- 删除检查注册选项状态的冗余代码逻辑
- 简化 OAuth 选项的条件判断表达式
- 修复密码注册功能的显示逻辑问题
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.

不允许通过密码注册时,注册界面仍会出现”使用用户名继续“