Feat: Implement Audit Logging and integrate into Reservation actions
This commit is contained in:
21
src/lib/logger.ts
Normal file
21
src/lib/logger.ts
Normal file
@@ -0,0 +1,21 @@
|
||||
import { createClient } from "@/lib/supabase/server"
|
||||
|
||||
export async function logAction(
|
||||
action: string,
|
||||
entityType: string,
|
||||
entityId: string,
|
||||
details?: any
|
||||
) {
|
||||
const supabase = await createClient()
|
||||
const { data: { user } } = await supabase.auth.getUser()
|
||||
|
||||
if (!user) return
|
||||
|
||||
await supabase.from('audit_logs').insert({
|
||||
user_id: user.id,
|
||||
action,
|
||||
entity_type: entityType,
|
||||
entity_id: entityId,
|
||||
details,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user