feat: add city/state/country to complex, new settings page with sidebar, and Biome linting
- Added city, state, and country optional fields to Complex model - Updated onboarding to include optional location fields - Created new settings page with sidebar navigation (Datos del Complejo, Canchas) - Replaced ESLint with Biome for frontend and backend linting - Added parallel dev script with concurrently - Migrated register-routes to use direct app.route() pattern
This commit is contained in:
@@ -1,35 +1,32 @@
|
||||
import type { MiddlewareHandler } from 'hono'
|
||||
import { db } from '@/lib/prisma'
|
||||
import { supabase } from '@/lib/supabase'
|
||||
import type { AppEnv } from '@/types/hono'
|
||||
import { db } from '@/lib/prisma';
|
||||
import { supabase } from '@/lib/supabase';
|
||||
import type { AppEnv } from '@/types/hono';
|
||||
import type { MiddlewareHandler } from 'hono';
|
||||
|
||||
function getBearerToken(value: string | undefined): string | null {
|
||||
if (!value) return null
|
||||
const [scheme, token] = value.split(' ')
|
||||
if (scheme?.toLowerCase() !== 'bearer' || !token) return null
|
||||
return token
|
||||
if (!value) return null;
|
||||
const [scheme, token] = value.split(' ');
|
||||
if (scheme?.toLowerCase() !== 'bearer' || !token) return null;
|
||||
return token;
|
||||
}
|
||||
|
||||
export const requireAuth: MiddlewareHandler<AppEnv> = async (
|
||||
c,
|
||||
next,
|
||||
) => {
|
||||
const token = getBearerToken(c.req.header('authorization'))
|
||||
export const requireAuth: MiddlewareHandler<AppEnv> = async (c, next) => {
|
||||
const token = getBearerToken(c.req.header('authorization'));
|
||||
|
||||
if (!token) {
|
||||
return c.json({ message: 'Missing bearer token.' }, 403)
|
||||
return c.json({ message: 'Missing bearer token.' }, 403);
|
||||
}
|
||||
|
||||
const { data, error } = await supabase.auth.getUser(token)
|
||||
const { data, error } = await supabase.auth.getUser(token);
|
||||
|
||||
if (error || !data.user) {
|
||||
return c.json({ message: 'Invalid or expired token.' }, 403)
|
||||
return c.json({ message: 'Invalid or expired token.' }, 403);
|
||||
}
|
||||
|
||||
const email = data.user.email?.toLowerCase()
|
||||
const email = data.user.email?.toLowerCase();
|
||||
|
||||
if (!email) {
|
||||
return c.json({ message: 'Auth user does not contain email.' }, 403)
|
||||
return c.json({ message: 'Auth user does not contain email.' }, 403);
|
||||
}
|
||||
|
||||
const appUser = await db.user.findFirst({
|
||||
@@ -38,13 +35,13 @@ export const requireAuth: MiddlewareHandler<AppEnv> = async (
|
||||
email,
|
||||
},
|
||||
select: { id: true },
|
||||
})
|
||||
});
|
||||
|
||||
if (!appUser) {
|
||||
return c.json({ message: 'User not provisioned in backend.' }, 403)
|
||||
return c.json({ message: 'User not provisioned in backend.' }, 403);
|
||||
}
|
||||
|
||||
c.set('authUser', data.user)
|
||||
c.set('appUserId', appUser.id)
|
||||
await next()
|
||||
}
|
||||
c.set('authUser', data.user);
|
||||
c.set('appUserId', appUser.id);
|
||||
await next();
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user