Added Cors Hosts
This commit is contained in:
@@ -64,4 +64,45 @@ export default async function userRoutes(server: FastifyInstance) {
|
||||
profile,
|
||||
}
|
||||
})
|
||||
|
||||
server.put("/user/:id/profile", async (req, reply) => {
|
||||
|
||||
const { id } = req.params as { id?: string }
|
||||
|
||||
const { data } = req.body as { data?: object }
|
||||
|
||||
// 4. Profil für den aktiven Tenant laden
|
||||
let profile = null
|
||||
if (req.user.tenant_id) {
|
||||
const { data: profileData } = await server.supabase
|
||||
.from("auth_profiles")
|
||||
.select("*")
|
||||
.eq("user_id", req.user.user_id)
|
||||
.eq("tenant_id", req.user.tenant_id)
|
||||
.single()
|
||||
|
||||
profile = profileData
|
||||
}
|
||||
|
||||
console.log(data)
|
||||
|
||||
//Update Profile
|
||||
const { data: updatedProfileData, error: updateError } = await server.supabase
|
||||
.from("auth_profiles")
|
||||
.update(data)
|
||||
.eq("user_id", id)
|
||||
.eq("id", profile?.id)
|
||||
.select("*")
|
||||
.single()
|
||||
|
||||
console.log(updateError)
|
||||
console.log(updatedProfileData)
|
||||
|
||||
// 5. Permissions laden (über Funktion)
|
||||
|
||||
// 6. Response zurückgeben
|
||||
return {
|
||||
data,
|
||||
}
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user