Skip to content
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 34 additions & 13 deletions web/src/components/settings/personal/cards/AccountManagement.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ const AccountManagement = ({
setShowChangePasswordModal,
setShowAccountDeleteModal,
}) => {
const wechatEnabled = Boolean(status.wechat_login);
const isWeChatBound = Boolean(userState.user?.wechat_id);
const renderAccountInfo = (accountId, label) => {
if (!accountId || accountId === '') {
return <span className='text-gray-500'>{t('未绑定')}</span>;
Expand All @@ -83,6 +85,27 @@ const AccountManagement = ({
</Popover>
);
};

const getBindingStatusText = (enabled, bound) => {
if (!enabled) {
return t('未启用');
}
return bound ? t('已绑定') : t('未绑定');
};
Comment on lines +89 to +97

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

Make “未启用” take precedence in status text.

When a provider is disabled, show “未启用” even if the user had bound previously (matches PR intent).

Apply:

-  const getBindingStatusText = (enabled, bound) => {
-    if (bound) {
-      return t('已绑定');
-    }
-    if (!enabled) {
-      return t('未启用');
-    }
-    return t('未绑定');
-  };
+  const getBindingStatusText = (enabled, bound) => {
+    if (!enabled) return t('未启用');
+    return bound ? t('已绑定') : t('未绑定');
+  };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const getBindingStatusText = (enabled, bound) => {
if (bound) {
return t('已绑定');
}
if (!enabled) {
return t('未启用');
}
return t('未绑定');
};
const getBindingStatusText = (enabled, bound) => {
if (!enabled) return t('未启用');
return bound ? t('已绑定') : t('未绑定');
};
🤖 Prompt for AI Agents
In web/src/components/settings/personal/cards/AccountManagement.jsx around lines
89 to 97, the status text currently returns '已绑定' before checking whether the
provider is enabled; change the logic so the "not enabled" case takes precedence
by checking if (!enabled) first and returning t('未启用'), then check bound to
return t('已绑定') and finally return t('未绑定') as the fallback.


const getBindingButtonText = (enabled, bound) => {
if (bound) {
return t('修改绑定');
}
return enabled ? t('绑定') : t('未启用');
};

Comment on lines +99 to +105

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

Button label should also prioritize “未启用”.

Avoid showing “修改绑定/绑定” when disabled.

-  const getBindingButtonText = (enabled, bound) => {
-    if (bound) {
-      return t('修改绑定');
-    }
-    return enabled ? t('绑定') : t('未启用');
-  };
+  const getBindingButtonText = (enabled, bound) => {
+    if (!enabled) return t('未启用');
+    return bound ? t('修改绑定') : t('绑定');
+  };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const getBindingButtonText = (enabled, bound) => {
if (bound) {
return t('修改绑定');
}
return enabled ? t('绑定') : t('未启用');
};
const getBindingButtonText = (enabled, bound) => {
if (!enabled) return t('未启用');
return bound ? t('修改绑定') : t('绑定');
};
🤖 Prompt for AI Agents
In web/src/components/settings/personal/cards/AccountManagement.jsx around lines
99 to 105, the getBindingButtonText currently returns '修改绑定' when bound even if
the feature is disabled; change the logic to first check if enabled is false and
return t('未启用'), otherwise if bound return t('修改绑定'), else return t('绑定') so the
button never shows bind/modify when the feature is disabled.

const renderProviderBinding = (enabled, accountId, label) => {
if (!enabled) {
return <span className='text-gray-500'>{t('未启用')}</span>;
}
return renderAccountInfo(accountId, label);
};
Comment on lines +106 to +118

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

renderProviderBinding should show “未启用” even if bound.

Current check renders the account ID when disabled; flip the order.

   const renderProviderBinding = (enabled, accountId, label) => {
     const hasAccountId = Boolean(accountId && accountId !== '');
-
-    if (hasAccountId) {
-      return renderAccountInfo(accountId, label);
-    }
-
-    if (!enabled) {
-      return <span className='text-gray-500'>{t('未启用')}</span>;
-    }
-
-    return renderAccountInfo(accountId, label);
+    if (!enabled) {
+      return <span className='text-gray-500'>{t('未启用')}</span>;
+    }
+    return renderAccountInfo(accountId, label);
   };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const renderProviderBinding = (enabled, accountId, label) => {
const hasAccountId = Boolean(accountId && accountId !== '');
if (hasAccountId) {
return renderAccountInfo(accountId, label);
}
if (!enabled) {
return <span className='text-gray-500'>{t('未启用')}</span>;
}
return renderAccountInfo(accountId, label);
};
const renderProviderBinding = (enabled, accountId, label) => {
const hasAccountId = Boolean(accountId && accountId !== '');
if (!enabled) {
return <span className='text-gray-500'>{t('未启用')}</span>;
}
return renderAccountInfo(accountId, label);
};
🤖 Prompt for AI Agents
In web/src/components/settings/personal/cards/AccountManagement.jsx around lines
106 to 118, the rendering logic currently checks for accountId before enabled;
change the order so that if enabled is false you immediately return the "未启用"
span (even if accountId exists), otherwise proceed to check hasAccountId and
renderAccountInfo when present, falling back to your existing empty/default
rendering when enabled but no accountId. Ensure the enabled-check is evaluated
first so disabled providers always show "未启用".

return (
<Card className='!rounded-2xl'>
{/* 卡片头部 */}
Expand Down Expand Up @@ -165,9 +188,7 @@ const AccountManagement = ({
{t('微信')}
</div>
<div className='text-sm text-gray-500 truncate'>
{userState.user && userState.user.wechat_id !== ''
? t('已绑定')
: t('未绑定')}
{getBindingStatusText(wechatEnabled, isWeChatBound)}
</div>
</div>
</div>
Expand All @@ -176,14 +197,10 @@ const AccountManagement = ({
type='primary'
theme='outline'
size='small'
disabled={!status.wechat_login}
disabled={!wechatEnabled}
onClick={() => setShowWeChatBindModal(true)}
>
{userState.user && userState.user.wechat_id !== ''
? t('修改绑定')
: status.wechat_login
? t('绑定')
: t('未启用')}
{getBindingButtonText(wechatEnabled, isWeChatBound)}
</Button>
</div>
</div>
Expand All @@ -204,7 +221,8 @@ const AccountManagement = ({
{t('GitHub')}
</div>
<div className='text-sm text-gray-500 truncate'>
{renderAccountInfo(
{renderProviderBinding(
status.github_oauth,
userState.user?.github_id,
t('GitHub ID'),
)}
Comment on lines +234 to 238

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

Guard against undefined IDs in button disable logic (GitHub).

Elsewhere you compare to '', which disables the button if the field is undefined. Use a boolean check.

Apply inline change near the button:

- disabled={
-   (userState.user && userState.user.github_id !== '') ||
-   !status.github_oauth
- }
+ disabled={Boolean(userState.user?.github_id) || !status.github_oauth}

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In web/src/components/settings/personal/cards/AccountManagement.jsx around lines
224 to 228, the button disable logic currently compares the GitHub ID to an
empty string which fails when the ID is undefined; change the condition to a
boolean check so the button is disabled when the ID is falsy (e.g. use
!userState.user?.github_id or Boolean(userState.user?.github_id) accordingly)
and apply this inline where the button's disabled prop is set.

Expand Down Expand Up @@ -245,7 +263,8 @@ const AccountManagement = ({
{t('OIDC')}
</div>
<div className='text-sm text-gray-500 truncate'>
{renderAccountInfo(
{renderProviderBinding(
status.oidc_enabled,
userState.user?.oidc_id,
t('OIDC ID'),
)}
Comment on lines +276 to 280

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

Same undefined check for OIDC button.

- disabled={
-   (userState.user && userState.user.oidc_id !== '') ||
-   !status.oidc_enabled
- }
+ disabled={Boolean(userState.user?.oidc_id) || !status.oidc_enabled}

Committable suggestion skipped: line range outside the PR's diff.

🤖 Prompt for AI Agents
In web/src/components/settings/personal/cards/AccountManagement.jsx around lines
266 to 270, the OIDC provider binding button is rendered without the same
undefined/user existence guard used for other provider buttons; update the code
to only call renderProviderBinding when status.oidc_enabled is true and
userState.user exists and userState.user.oidc_id is defined (mirror the same
conditional check pattern used for the other provider buttons) so the component
isn’t invoked with an undefined ID.

Expand Down Expand Up @@ -289,7 +308,8 @@ const AccountManagement = ({
{t('Telegram')}
</div>
<div className='text-sm text-gray-500 truncate'>
{renderAccountInfo(
{renderProviderBinding(
status.telegram_oauth,
userState.user?.telegram_id,
t('Telegram ID'),
)}
Comment thread
RedwindA marked this conversation as resolved.
Resolved
Expand Down Expand Up @@ -334,7 +354,8 @@ const AccountManagement = ({
{t('LinuxDO')}
</div>
<div className='text-sm text-gray-500 truncate'>
{renderAccountInfo(
{renderProviderBinding(
status.linuxdo_oauth,
userState.user?.linux_do_id,
t('LinuxDO ID'),
)}
Comment thread
RedwindA marked this conversation as resolved.
Resolved
Expand Down