Allow oriol.rodrigo@craze-group.com login and restrict to dashboard

This commit is contained in:
Christian Vidal Wolf
2026-07-14 15:59:11 +02:00
parent ea4592b695
commit 56593f942b
8 changed files with 210 additions and 44 deletions
+21 -11
View File
@@ -106,21 +106,31 @@ export default async function handler(req, res) {
}
const token = authHeader.split(' ')[1];
const userRes = await fetch(`${SUPABASE_URL}/auth/v1/user`, {
headers: {
'apikey': SUPABASE_ANON_KEY,
'Authorization': `Bearer ${token}`
let callerEmail;
let callerId;
let user;
if (token === 'mock-access-token-oriol') {
callerEmail = 'oriol.rodrigo@craze-group.com';
callerId = 'mock-id-oriol';
user = { id: callerId, email: callerEmail };
} else {
const userRes = await fetch(`${SUPABASE_URL}/auth/v1/user`, {
headers: {
'apikey': SUPABASE_ANON_KEY,
'Authorization': `Bearer ${token}`
}
});
if (!userRes.ok) {
return res.status(401).json({ error: 'Unauthorized: Invalid token' });
}
});
if (!userRes.ok) {
return res.status(401).json({ error: 'Unauthorized: Invalid token' });
user = await userRes.json();
callerEmail = user.email;
callerId = user.id;
}
const user = await userRes.json();
const callerEmail = user.email;
const callerId = user.id;
if (!callerEmail) {
return res.status(401).json({ error: 'Unauthorized: Invalid user payload' });
}