This commit is contained in:
David Nguyen
2025-02-12 18:39:00 +11:00
parent 15922d447b
commit 4c57095ee1
11 changed files with 72 additions and 231 deletions

View File

@ -5,8 +5,9 @@ import { formatDocumentsPath } from '@documenso/lib/utils/teams';
export function loader() {
const { currentTeam } = getLoaderSession();
if (!currentTeam) {
throw redirect('/documents');
throw redirect('/settings/teams');
}
throw redirect(formatDocumentsPath(currentTeam.url));

View File

@ -19,7 +19,7 @@ export const loader = () => {
const { currentTeam } = getLoaderSession();
if (!currentTeam) {
throw redirect('/documents');
throw redirect('/settings/teams');
}
const trpcHeaders = {

View File

@ -97,7 +97,6 @@
"typescript": "5.6.2",
"vite": "^6.1.0",
"vite-plugin-babel-macros": "^1.0.6",
"vite-plugin-checker": "^0.8.0",
"vite-tsconfig-paths": "^5.1.4"
}
}
}

View File

@ -1,7 +1,6 @@
import type { Context, Next } from 'hono';
import { getCookie } from 'hono/cookie';
import { setCsrfCookie } from '@documenso/auth/server/lib/session/session-cookies';
import { AppLogger } from '@documenso/lib/utils/debugger';
const logger = new AppLogger('Middleware');
@ -32,14 +31,6 @@ export const appMiddleware = async (c: Context, next: Next) => {
const referrerUrl = referrer ? new URL(referrer) : null;
const referrerPathname = referrerUrl ? referrerUrl.pathname : null;
// Set csrf token if not set.
const csrfToken = getCookie(c, 'csrfToken');
// Todo: Currently not working.
if (!csrfToken) {
await setCsrfCookie(c);
}
// // Whether to reset the preferred team url cookie if the user accesses a non team page from a team page.
// const resetPreferredTeamUrl =
// referrerPathname &&
@ -59,24 +50,6 @@ export const appMiddleware = async (c: Context, next: Next) => {
// return c.redirect(redirectUrl);
// }
// // Redirect `/t` to `/settings/teams`.
// if (path === '/t' || path === '/t/') {
// logger.log('Redirecting to /settings/teams');
// const redirectUrl = new URL('/settings/teams', req.url);
// return c.redirect(redirectUrl);
// }
// // Redirect `/t/<team_url>` to `/t/<team_url>/documents`.
// if (TEAM_URL_ROOT_REGEX.test(path)) {
// logger.log('Redirecting team documents');
// const redirectUrl = new URL(`${path}/documents`, req.url);
// setCookie(c, 'preferred-team-url', path.replace('/t/', ''));
// return c.redirect(redirectUrl);
// }
// // Set the preferred team url cookie if user accesses a team page.
// if (path.startsWith('/t/')) {
// setCookie(c, 'preferred-team-url', path.split('/')[2]);
@ -90,6 +63,4 @@ export const appMiddleware = async (c: Context, next: Next) => {
// deleteCookie(c, 'preferred-team-url');
// return next();
// }
return next();
};

View File

@ -9,7 +9,6 @@ import { openApiDocument } from '@documenso/trpc/server/open-api';
import { filesRoute } from './api/files';
import { type AppContext, appContext } from './context';
import { appMiddleware } from './middleware';
import { openApiTrpcServerHandler } from './trpc/hono-trpc-open-api';
import { reactRouterTrpcServer } from './trpc/hono-trpc-remix';
@ -30,7 +29,7 @@ app.use(appContext);
/**
* Middleware for initial page loads.
*/
app.use('*', appMiddleware);
// app.use('*', appMiddleware);
// Auth server.
app.route('/api/auth', auth);