Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
赵月辉
/
fastgpt-migrated
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
Unverified
Commit
c9f4bad7
authored
Aug 16, 2023
by
archer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: file
parent
0455bdea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
client/src/utils/plugin/google.ts
+37
-0
No files found.
client/src/utils/plugin/google.ts
0 → 100644
View file @
c9f4bad7
import
axios
from
'axios'
;
import
{
Obj2Query
}
from
'../tools'
;
export
const
getClientToken
=
(
googleClientVerKey
?:
string
)
=>
{
if
(
!
googleClientVerKey
||
typeof
window
.
grecaptcha
===
'undefined'
||
!
window
.
grecaptcha
?.
ready
)
return
''
;
return
new
Promise
<
string
>
((
resolve
,
reject
)
=>
{
window
.
grecaptcha
.
ready
(
async
()
=>
{
try
{
const
token
=
await
window
.
grecaptcha
.
execute
(
googleClientVerKey
,
{
action
:
'submit'
});
resolve
(
token
);
}
catch
(
error
)
{
reject
(
error
);
}
});
});
};
// service run
export
const
authGoogleToken
=
async
(
data
:
{
secret
:
string
;
response
:
string
;
remoteip
?:
string
;
})
=>
{
const
res
=
await
axios
.
post
<
{
score
?:
number
;
success
:
boolean
;
'error-codes'
:
string
[];
}
>
(
`https://www.recaptcha.net/recaptcha/api/siteverify?
${
Obj2Query
(
data
)}
`
);
if
(
res
.
data
.
success
)
{
return
Promise
.
resolve
(
''
);
}
return
Promise
.
reject
(
res
?.
data
?.[
'error-codes'
]?.[
0
]
||
'非法环境'
);
};
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