Skip to content

Supercharge your AI agents with data from the web and beyond. Building the library for superintelligence. 🔥

Update auth.ts

Nicolase99c2568f440
diff --git a/apps/api/src/controllers/auth.ts b/apps/api/src/controllers/auth.ts
index 7154c6943..035d847db 100644
--- a/apps/api/src/controllers/auth.ts
+++ b/apps/api/src/controllers/auth.ts
@@ -88,15 +88,10 @@ export async function supaAuthenticateUser(
// console.log('Key and Price ID:', data);
}
- if(error) {
- return {
- success: false,
- error: "Unauthorized: Invalid token or server error.",
- status: 500,
- };
- }
+
- if (!data || data.length === 0) {
+ if (error || !data || data.length === 0) {
+ Logger.warn(`Error fetching api key: ${error.message} or data is empty`);
return {
success: false,
error: "Unauthorized: Invalid token",
@@ -186,16 +181,10 @@ export async function supaAuthenticateUser(
.select("*")
.eq("key", normalizedApi);
- if (error) {
- Logger.warn(`Error fetching api key: ${error.message}`);
- return {
- success: false,
- error: "Unauthorized: Invalid token or server error.",
- status: 500,
- };
- }
+
- if (!data || data.length === 0) {
+ if (error || !data || data.length === 0) {
+ Logger.warn(`Error fetching api key: ${error.message} or data is empty`);
return {
success: false,
error: "Unauthorized: Invalid token",