Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
phsl
/
new-api
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
722e2c2a
authored
Sep 29, 2025
by
Seefs
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: passkey wip
parent
1599a840
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
25 deletions
+25
-25
web/src/components/table/channels/modals/EditChannelModal.jsx
+3
-12
web/src/hooks/common/useSecureVerification.jsx
+0
-6
web/src/services/secureVerification.js
+22
-7
No files found.
web/src/components/table/channels/modals/EditChannelModal.jsx
View file @
722e2c2a
...
@@ -215,13 +215,13 @@ const EditChannelModal = (props) => {
...
@@ -215,13 +215,13 @@ const EditChannelModal = (props) => {
onSuccess
:
(
result
)
=>
{
onSuccess
:
(
result
)
=>
{
// 验证成功后显示密钥
// 验证成功后显示密钥
if
(
result
.
success
&&
result
.
data
?.
key
)
{
if
(
result
.
success
&&
result
.
data
?.
key
)
{
showSuccess
(
t
(
'密钥获取成功'
));
setKeyDisplayState
({
setKeyDisplayState
({
showModal
:
true
,
showModal
:
true
,
keyData
:
result
.
data
.
key
,
keyData
:
result
.
data
.
key
,
});
});
}
}
},
},
successMessage
:
t
(
'密钥获取成功'
),
});
});
// 重置密钥显示状态
// 重置密钥显示状态
...
@@ -607,24 +607,15 @@ const EditChannelModal = (props) => {
...
@@ -607,24 +607,15 @@ const EditChannelModal = (props) => {
// 显示安全验证模态框并开始验证流程
// 显示安全验证模态框并开始验证流程
const
handleShow2FAModal
=
async
()
=>
{
const
handleShow2FAModal
=
async
()
=>
{
try
{
try
{
console
.
log
(
'=== handleShow2FAModal called ==='
);
console
.
log
(
'channelId:'
,
channelId
);
console
.
log
(
'startVerification function:'
,
typeof
startVerification
);
// 测试模态框状态
console
.
log
(
'Current modal state:'
,
isModalVisible
);
const
apiCall
=
createApiCalls
.
viewChannelKey
(
channelId
);
const
apiCall
=
createApiCalls
.
viewChannelKey
(
channelId
);
console
.
log
(
'apiCall created:'
,
typeof
apiCall
);
const
result
=
await
startVerification
(
apiCall
,
{
await
startVerification
(
apiCall
,
{
title
:
t
(
'查看渠道密钥'
),
title
:
t
(
'查看渠道密钥'
),
description
:
t
(
'为了保护账户安全,请验证您的身份。'
),
description
:
t
(
'为了保护账户安全,请验证您的身份。'
),
preferredMethod
:
'passkey'
,
// 优先使用 Passkey
preferredMethod
:
'passkey'
,
// 优先使用 Passkey
});
});
console
.
log
(
'startVerification result:'
,
result
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
'
handleShow2FAModal error
:'
,
error
);
console
.
error
(
'
Failed to start verification
:'
,
error
);
showError
(
error
.
message
||
t
(
'启动验证失败'
));
showError
(
error
.
message
||
t
(
'启动验证失败'
));
}
}
};
};
...
...
web/src/hooks/common/useSecureVerification.jsx
View file @
722e2c2a
...
@@ -81,17 +81,13 @@ export const useSecureVerification = ({
...
@@ -81,17 +81,13 @@ export const useSecureVerification = ({
// 开始验证流程
// 开始验证流程
const
startVerification
=
useCallback
(
async
(
apiCall
,
options
=
{})
=>
{
const
startVerification
=
useCallback
(
async
(
apiCall
,
options
=
{})
=>
{
console
.
log
(
'startVerification called:'
,
{
apiCall
,
options
});
const
{
preferredMethod
,
title
,
description
}
=
options
;
const
{
preferredMethod
,
title
,
description
}
=
options
;
// 检查验证方式
// 检查验证方式
console
.
log
(
'Checking verification methods...'
);
const
methods
=
await
checkVerificationMethods
();
const
methods
=
await
checkVerificationMethods
();
console
.
log
(
'Verification methods:'
,
methods
);
if
(
!
methods
.
has2FA
&&
!
methods
.
hasPasskey
)
{
if
(
!
methods
.
has2FA
&&
!
methods
.
hasPasskey
)
{
const
errorMessage
=
t
(
'您需要先启用两步验证或 Passkey 才能执行此操作'
);
const
errorMessage
=
t
(
'您需要先启用两步验证或 Passkey 才能执行此操作'
);
console
.
error
(
'No verification methods available:'
,
errorMessage
);
showError
(
errorMessage
);
showError
(
errorMessage
);
onError
?.(
new
Error
(
errorMessage
));
onError
?.(
new
Error
(
errorMessage
));
return
false
;
return
false
;
...
@@ -106,7 +102,6 @@ export const useSecureVerification = ({
...
@@ -106,7 +102,6 @@ export const useSecureVerification = ({
defaultMethod
=
'2fa'
;
defaultMethod
=
'2fa'
;
}
}
}
}
console
.
log
(
'Selected verification method:'
,
defaultMethod
);
setVerificationState
(
prev
=>
({
setVerificationState
(
prev
=>
({
...
prev
,
...
prev
,
...
@@ -116,7 +111,6 @@ export const useSecureVerification = ({
...
@@ -116,7 +111,6 @@ export const useSecureVerification = ({
description
description
}));
}));
setIsModalVisible
(
true
);
setIsModalVisible
(
true
);
console
.
log
(
'Modal should be visible now'
);
return
true
;
return
true
;
},
[
checkVerificationMethods
,
onError
,
t
]);
},
[
checkVerificationMethods
,
onError
,
t
]);
...
...
web/src/services/secureVerification.js
View file @
722e2c2a
...
@@ -34,24 +34,39 @@ export class SecureVerificationService {
...
@@ -34,24 +34,39 @@ export class SecureVerificationService {
*/
*/
static
async
checkAvailableVerificationMethods
()
{
static
async
checkAvailableVerificationMethods
()
{
try
{
try
{
console
.
log
(
'Checking user verification methods...'
);
const
[
twoFAResponse
,
passkeyResponse
,
passkeySupported
]
=
await
Promise
.
all
([
const
[
twoFAResponse
,
passkeyResponse
,
passkeySupported
]
=
await
Promise
.
all
([
API
.
get
(
'/api/user/2fa/status'
),
API
.
get
(
'/api/user/2fa/status'
),
API
.
get
(
'/api/user/passkey'
),
API
.
get
(
'/api/user/passkey'
),
isPasskeySupported
()
isPasskeySupported
()
]);
]);
console
.
log
(
'2FA response:'
,
twoFAResponse
);
console
.
log
(
'=== DEBUGGING VERIFICATION METHODS ==='
);
console
.
log
(
'Passkey response:'
,
passkeyResponse
);
console
.
log
(
'2FA Response:'
,
JSON
.
stringify
(
twoFAResponse
,
null
,
2
));
console
.
log
(
'Passkey browser support:'
,
passkeySupported
);
console
.
log
(
'Passkey Response:'
,
JSON
.
stringify
(
passkeyResponse
,
null
,
2
));
const
has2FA
=
twoFAResponse
.
data
?.
success
&&
twoFAResponse
.
data
?.
data
?.
enabled
===
true
;
const
hasPasskey
=
passkeyResponse
.
data
?.
success
&&
passkeyResponse
.
data
?.
data
?.
enabled
===
true
;
console
.
log
(
'has2FA calculation:'
,
{
success
:
twoFAResponse
.
data
?.
success
,
dataExists
:
!!
twoFAResponse
.
data
?.
data
,
enabled
:
twoFAResponse
.
data
?.
data
?.
enabled
,
result
:
has2FA
});
console
.
log
(
'hasPasskey calculation:'
,
{
success
:
passkeyResponse
.
data
?.
success
,
dataExists
:
!!
passkeyResponse
.
data
?.
data
,
enabled
:
passkeyResponse
.
data
?.
data
?.
enabled
,
result
:
hasPasskey
});
const
result
=
{
const
result
=
{
has2FA
:
twoFAResponse
.
success
&&
twoFAResponse
.
data
?.
enabled
===
true
,
has2FA
,
hasPasskey
:
passkeyResponse
.
success
&&
(
passkeyResponse
.
data
?.
enabled
===
true
||
passkeyResponse
.
data
?.
status
===
'enabled'
||
passkeyResponse
.
data
!==
null
)
,
hasPasskey
,
passkeySupported
passkeySupported
};
};
console
.
log
(
'Final verification methods result:'
,
result
);
return
result
;
return
result
;
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
error
(
'Failed to check verification methods:'
,
error
);
console
.
error
(
'Failed to check verification methods:'
,
error
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment