fix: handle binded_redirect state inconsistency in WeChat login
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -385,10 +385,27 @@ async function _runLogin({ callId, timeoutMs, botType, emit, isAborted }) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case 'binded_redirect':
|
case 'binded_redirect': {
|
||||||
log.info('weixin', `callId=${callId} already connected`);
|
// WeChat server considers this OpenClaw already bound.
|
||||||
emit({ action: 'finish', event: 'success', data: { accountId: 'already_connected' } });
|
// Check if local token exists — if yes, treat as success; if not, local state was
|
||||||
|
// cleared (e.g. logout) but remote binding wasn't revoked → state inconsistency.
|
||||||
|
const indexedIds = _listIndexedAccountIds();
|
||||||
|
const hasLocalToken = indexedIds.some(id => {
|
||||||
|
const acct = _loadAccount(id);
|
||||||
|
return acct && acct.token;
|
||||||
|
});
|
||||||
|
if (hasLocalToken) {
|
||||||
|
log.info('weixin', `callId=${callId} already connected, local token intact`);
|
||||||
|
emit({ action: 'finish', event: 'success', data: { accountId: indexedIds[0] } });
|
||||||
|
} else {
|
||||||
|
log.warn('weixin', `callId=${callId} binded_redirect but local token missing — state inconsistency`);
|
||||||
|
emit({
|
||||||
|
action: 'finish', event: 'failed', code: 1010,
|
||||||
|
message: '微信服务端已绑定,但本地登录状态已清除。请在微信公众号后台解绑此 OpenClaw 后重新扫码登录。',
|
||||||
|
});
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
case 'confirmed': {
|
case 'confirmed': {
|
||||||
if (!status.ilink_bot_id) throw new Error('confirmed: missing ilink_bot_id');
|
if (!status.ilink_bot_id) throw new Error('confirmed: missing ilink_bot_id');
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "clawd",
|
"name": "clawd",
|
||||||
"version": "1.4.0",
|
"version": "1.4.1",
|
||||||
"description": "Claw Box daemon - connects local Linux box to claw.cutos.ai via WebSocket",
|
"description": "Claw Box daemon - connects local Linux box to claw.cutos.ai via WebSocket",
|
||||||
"main": "lib/client.js",
|
"main": "lib/client.js",
|
||||||
"bin": {
|
"bin": {
|
||||||
|
|||||||
Reference in New Issue
Block a user