mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-04-26 21:07:52 +00:00
fix local node auth
This commit is contained in:
parent
f89771eaf4
commit
ac7b00662f
@ -82,8 +82,14 @@ export const NotAuthenticated = ({
|
|||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
if (data?.height) {
|
if (data?.height) {
|
||||||
setHasLocalNode(true);
|
setHasLocalNode(true);
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
return false
|
||||||
|
|
||||||
}
|
}
|
||||||
} catch (error) {}
|
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -122,8 +128,9 @@ export const NotAuthenticated = ({
|
|||||||
const validateApiKey = useCallback(async (key, fromStartUp) => {
|
const validateApiKey = useCallback(async (key, fromStartUp) => {
|
||||||
try {
|
try {
|
||||||
if (!currentNodeRef.current) return;
|
if (!currentNodeRef.current) return;
|
||||||
|
const stillHasLocal = await checkIfUserHasLocalNode()
|
||||||
const isLocalKey = cleanUrl(key?.url) === "127.0.0.1:12391";
|
const isLocalKey = cleanUrl(key?.url) === "127.0.0.1:12391";
|
||||||
if (isLocalKey && !hasLocalNodeRef.current && !fromStartUp) {
|
if (isLocalKey && !stillHasLocal && !fromStartUp) {
|
||||||
throw new Error("Please turn on your local node");
|
throw new Error("Please turn on your local node");
|
||||||
}
|
}
|
||||||
const isCurrentNodeLocal =
|
const isCurrentNodeLocal =
|
||||||
@ -185,6 +192,26 @@ export const NotAuthenticated = ({
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
setIsValidApiKey(false);
|
setIsValidApiKey(false);
|
||||||
setUseLocalNode(false);
|
setUseLocalNode(false);
|
||||||
|
if(fromStartUp){
|
||||||
|
setCurrentNode({
|
||||||
|
url: "http://127.0.0.1:12391",
|
||||||
|
});
|
||||||
|
window
|
||||||
|
.sendMessage("setApiKey", null)
|
||||||
|
.then((response) => {
|
||||||
|
if (response) {
|
||||||
|
setApiKey(null);
|
||||||
|
handleSetGlobalApikey(null);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((error) => {
|
||||||
|
console.error(
|
||||||
|
"Failed to set API key:",
|
||||||
|
error.message || "An error occurred"
|
||||||
|
);
|
||||||
|
});
|
||||||
|
return
|
||||||
|
}
|
||||||
setInfoSnack({
|
setInfoSnack({
|
||||||
type: "error",
|
type: "error",
|
||||||
message: error?.message || "Select a valid apikey",
|
message: error?.message || "Select a valid apikey",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user