File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,31 @@ export const LoginForm: FC = () => {
6161
6262 const onGoFeishuLogin = ( ) => onGoLogin ( "feishu" ) ;
6363 const onGoDingTalkLogin = ( ) => onGoLogin ( "dingTalk" ) ;
64+
65+ const isWebauthnAvailable = ( ) => {
66+ return ! ! (
67+ navigator . credentials &&
68+ // @ts -expect-error
69+ navigator . credentials . create &&
70+ // @ts -expect-error
71+ navigator . credentials . get &&
72+ window . PublicKeyCredential
73+ ) ;
74+ } ;
75+
76+ const isWebauthnConditionalAvailable = ( ) => {
77+ return ! ! window . PublicKeyCredential ?. isConditionalMediationAvailable ?.( ) ;
78+ } ;
79+
6480 const onPasskeyLogin = async ( conditional ?: boolean ) => {
81+ if ( ! isWebauthnAvailable ( ) ) {
82+ if ( ! conditional ) toast . error ( "当前浏览器不支持 webauthn" ) ;
83+ return
84+ }
85+ if ( conditional && ! isWebauthnConditionalAvailable ( ) ) {
86+ return
87+ }
88+
6589 try {
6690 const {
6791 data : { data : options } ,
You can’t perform that action at this time.
0 commit comments