Explorar o código

web: Add better logging

ghorsington %!s(int64=4) %!d(string=hai) anos
pai
achega
ea8d4f19f5
Modificáronse 2 ficheiros con 10 adicións e 1 borrados
  1. 1 0
      web/src/routes/login/discord.ts
  2. 9 1
      web/src/routes/rules/verify.ts

+ 1 - 0
web/src/routes/login/discord.ts

@@ -52,6 +52,7 @@ export const post = async (req: ExpressRequest, res: ExpressResponse):
         logger.error("WEB: failed to auth user %s: %s", userResult.id, userInServerResult.error);
         return res.json({ ok: false, error: "Couldn't determine if user joined the server, please try again later" });
     }
+    logger.verbose("Logged in as %s#%s (%s); user in server: (%s)", userResult.username, userResult.discriminator, userResult.id, userInServerResult.result.exists);
     if (!userInServerResult.result.exists) {
         return res.json({ ok: false, error: "You haven't joined any servers NoctBot manages! Please join first and try again!" });
     }

+ 9 - 1
web/src/routes/rules/verify.ts

@@ -29,9 +29,17 @@ export const get = async (req: ExpressRequest, res: ExpressResponse): GetResult
             userVerified: true,
         });
     }
+    const verifiedResult = await tryDo(rpcClient.userVerified({ userId: req.session.userId }));
+    let verified = true;
+    if (!verifiedResult.ok) {
+        logger.error("Failed to check verified state: %s", verifiedResult.error);
+    } else {
+        verified = verifiedResult.result.verified;
+        logger.verbose("User %s (%s) verified: %s", req.session.username, req.session.userId, verified);
+    }
     return res.json({
         captchaSitekey: ENV.HCAPTCHA_SITEKEY,
-        userVerified: (await rpcClient.userVerified({ userId: req.session.userId })).verified,
+        userVerified: verified,
     });
 };