Update auth.ts

This commit is contained in:
Nicolas 2024-07-29 18:44:18 -04:00
parent 968a2dc753
commit e99c2568f4

View File

@ -88,15 +88,10 @@ export async function supaAuthenticateUser(
// console.log('Key and Price ID:', data); // 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 { return {
success: false, success: false,
error: "Unauthorized: Invalid token", error: "Unauthorized: Invalid token",
@ -186,16 +181,10 @@ export async function supaAuthenticateUser(
.select("*") .select("*")
.eq("key", normalizedApi); .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 { return {
success: false, success: false,
error: "Unauthorized: Invalid token", error: "Unauthorized: Invalid token",