feat: add logging for user and organization details in middleware and enhance organization creation with transaction support

This commit is contained in:
Rotimi Best
2026-03-11 14:38:03 +01:00
parent 1db55ec933
commit a5157f7c6d
6 changed files with 53 additions and 18 deletions
+3
View File
@@ -11,6 +11,7 @@ import { isUserOrgAdmin } from '@cio/db/queries/organization';
export const orgAdminMiddleware = async (c: Context, next: Next) => {
try {
const user = c.get('user');
console.log('orgAdminMiddleware user', user);
if (!user) {
return c.json(
{
@@ -23,6 +24,7 @@ export const orgAdminMiddleware = async (c: Context, next: Next) => {
}
const orgId = c.req.header('cio-org-id');
console.log('orgAdminMiddleware orgId', orgId);
if (!orgId) {
return c.json(
@@ -36,6 +38,7 @@ export const orgAdminMiddleware = async (c: Context, next: Next) => {
}
const isAdmin = await isUserOrgAdmin(orgId, user.id);
console.log('orgAdminMiddleware isAdmin', isAdmin);
if (!isAdmin) {
return c.json(
{
+1
View File
@@ -10,6 +10,7 @@ import { getUserOrgRole } from '@cio/db/queries/organization';
*/
export const orgMemberMiddleware = async (c: Context, next: Next) => {
try {
console.log('user', c.get('user'));
const user = c.get('user');
if (!user) {
return c.json(
@@ -10,6 +10,8 @@ import { isUserOrgTeamMember } from '@cio/db/queries/organization';
*/
export const orgTeamMemberMiddleware = async (c: Context, next: Next) => {
try {
console.log('orgTeamMemberMiddleware user', c.get('user'));
const user = c.get('user');
if (!user) {
return c.json(