feat: add organisations (#1820)

This commit is contained in:
David Nguyen
2025-06-10 11:49:52 +10:00
committed by GitHub
parent 0b37f19641
commit e6dc237ad2
631 changed files with 37616 additions and 25695 deletions
+11 -19
View File
@@ -1,8 +1,10 @@
import type { Context, Next } from 'hono';
import { deleteCookie, setCookie } from 'hono/cookie';
import { setCookie } from 'hono/cookie';
import { AppDebugger } from '@documenso/lib/utils/debugger';
import { handleRedirects } from './redirects';
const debug = new AppDebugger('Middleware');
/**
@@ -24,6 +26,14 @@ export const appMiddleware = async (c: Context, next: Next) => {
}
// PRE-HANDLER CODE: Place code here to execute BEFORE the route handler runs.
const redirectPath = await handleRedirects(c);
if (redirectPath) {
debug.log('Redirecting from', path);
debug.log('Redirecting to', redirectPath);
return c.redirect(redirectPath);
}
await next();
@@ -35,15 +45,6 @@ export const appMiddleware = async (c: Context, next: Next) => {
debug.log('Path', path);
const pathname = path.replace('.data', '');
const referrer = c.req.header('referer');
const referrerUrl = referrer ? new URL(referrer) : null;
const referrerPathname = referrerUrl ? referrerUrl.pathname : null;
// Whether to reset the preferred team url cookie if the user accesses a non team page from a team page.
const resetPreferredTeamUrl =
referrerPathname &&
referrerPathname.startsWith('/t/') &&
(!pathname.startsWith('/t/') || pathname === '/');
// Set the preferred team url cookie if user accesses a team page.
if (pathname.startsWith('/t/')) {
@@ -55,15 +56,6 @@ export const appMiddleware = async (c: Context, next: Next) => {
return;
}
// Clear preferred team url cookie if user accesses a non team page from a team page.
if (resetPreferredTeamUrl || pathname === '/documents') {
debug.log('Deleting preferred team url cookie');
deleteCookie(c, 'preferred-team-url');
return;
}
};
// This regex matches any path that: