Skip to content

Commit

Permalink
fdg
Browse files Browse the repository at this point in the history
  • Loading branch information
codergautam committed Oct 18, 2024
1 parent c679f74 commit 81b6b71
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
11 changes: 11 additions & 0 deletions components/auth/auth.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ export function useSession() {
}
}

// check if crazygames
if(window.location.hostname.includes("crazygames")) {

if(window.verifyPayload && JSON.parse(window.verifyPayload).secret === "not_logged_in") {
// not loading
return {
data: null
}
}
}

if(session === false && !window.fetchingSession && window.cConfig?.apiUrl) {
let secret = null;
try {
Expand Down
15 changes: 11 additions & 4 deletions components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,14 @@ export default function Home({ }) {
if(data.secret && data.username) {
setSession({ token: { secret: data.secret, username: data.username } })
// verify the ws
window.verifyPayload = JSON.stringify({ type: "verify", secret: data.secret, username: data.username });

setWs((prev) => {

if(prev) {
console.log("sending verify", { type: "verify", secret: data.secret, username: data.username })
console.log("sending verify")

prev.send(JSON.stringify({ type: "verify", secret: data.secret, username: data.username }))
prev.send(window.verifyPayload)
}
return prev;
});
Expand All @@ -231,9 +234,12 @@ export default function Home({ }) {
console.log("crazygames user not logged in")
// user not logged in
// verify with not_logged_in
window.verifyPayload = JSON.stringify({ type: "verify", secret: "not_logged_in", username: "not_logged_in" });
setWs((prev) => {
if(prev) {
prev.send(JSON.stringify({ type: "verify", secret: "not_logged_in", username: "not_logged_in" }))
prev.send(window.verifyPayload)
} else {
console.log("no ws, waiting for connection")
}
return prev;
});
Expand Down Expand Up @@ -819,7 +825,8 @@ setShowCountryButtons(false)
window.verified = true;
}
ws.send(JSON.stringify({ type: "verify", secret, tz}))
} else {
} else if(inCrazyGames && window.verifyPayload) {
ws.send(window.verifyPayload)


}
Expand Down

0 comments on commit 81b6b71

Please sign in to comment.