mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-04-23 19:37:52 +00:00
change apikey validation
This commit is contained in:
parent
df87ca4d92
commit
fe04bd5b97
@ -197,18 +197,13 @@ export const NotAuthenticated = ({
|
|||||||
url: key?.url,
|
url: key?.url,
|
||||||
apikey: key?.apikey,
|
apikey: key?.apikey,
|
||||||
});
|
});
|
||||||
const url = `${key?.url}/admin/apikey/test`;
|
const url = `${key?.url}/lists/testlist?apiKey=${key?.apikey}`;
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url);
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
accept: "text/plain",
|
|
||||||
"X-API-KEY": key?.apikey, // Include the API key here
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Assuming the response is in plain text and will be 'true' or 'false'
|
// Assuming the response is in plain text and will be 'true' or 'false'
|
||||||
const data = await response.text();
|
const data = await response.json();
|
||||||
if (data === "true") {
|
|
||||||
|
if (data && !data?.error) {
|
||||||
setIsValidApiKey(true);
|
setIsValidApiKey(true);
|
||||||
setUseLocalNode(true);
|
setUseLocalNode(true);
|
||||||
return
|
return
|
||||||
@ -240,18 +235,13 @@ export const NotAuthenticated = ({
|
|||||||
} else if (currentNodeRef.current) {
|
} else if (currentNodeRef.current) {
|
||||||
payload = currentNodeRef.current;
|
payload = currentNodeRef.current;
|
||||||
}
|
}
|
||||||
const url = `${payload?.url}/admin/apikey/test`;
|
const url = `${payload?.url}/lists/testlist?apiKey=${payload?.apikey}`;
|
||||||
const response = await fetch(url, {
|
const response = await fetch(url);
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
accept: "text/plain",
|
|
||||||
"X-API-KEY": payload?.apikey, // Include the API key here
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
// Assuming the response is in plain text and will be 'true' or 'false'
|
// Assuming the response is in plain text and will be 'true' or 'false'
|
||||||
const data = await response.text();
|
const data = await response.json();
|
||||||
if (data === "true") {
|
|
||||||
|
if (data && !data?.error) {
|
||||||
window
|
window
|
||||||
.sendMessage("setApiKey", payload)
|
.sendMessage("setApiKey", payload)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user