Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
codergautam committed Oct 17, 2024
1 parent 118a8da commit 074725e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
6 changes: 3 additions & 3 deletions api/crazyAuth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as jwt from "jsonwebtoken";
import jwt from "jsonwebtoken";
const { verify } = jwt;
import axios from "axios";
// import { createUUID } from "@/components/createUUID";
// import User from "@/models/User";
Expand Down Expand Up @@ -26,8 +27,7 @@ export default async function handler(req, res) {
try {
const resp = await axios.get("https://sdk.crazygames.com/publicKey.json");
const publicKey = resp.data["publicKey"];
decodedToken = jwt.verify(token, publicKey, { algorithms: ["RS256"] });
console.log(decodedToken);
decodedToken = verify(token, publicKey, { algorithms: ["RS256"] });
} catch (error) {
return res.status(400).json({ error: 'Invalid token' });
}
Expand Down
5 changes: 3 additions & 2 deletions components/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,9 +210,10 @@ export default function Home({ }) {
if(data.secret && data.username) {
setSession({ token: { secret: data.secret, username: data.username } })
// verify the ws
console.log("sending verify", ws)
setWs((prev) => {
if(prev) {
console.log("sending verify", { type: "verify", secret: data.secret, username: data.username })

prev.send(JSON.stringify({ type: "verify", secret: data.secret, username: data.username }))
}
return prev;
Expand Down Expand Up @@ -639,7 +640,7 @@ setShowCountryButtons(false)
if(!session?.token?.secret) return;

// verify the ws
if(ws && !window.verified) {
if(ws && !window.verified && !window.location.search.includes("crazygames")) {
console.log("sending verify", ws)
ws.send(JSON.stringify({ type: "verify", secret: session.token.secret, username: session.token.username }))
}
Expand Down

0 comments on commit 074725e

Please sign in to comment.