mirror of
https://github.com/documenso/documenso.git
synced 2026-08-23 14:52:23 +10:00
feat: unify settings (#3128)
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import { PREFERRED_TEAM_URL_COOKIE } from '@documenso/lib/constants/cookies';
|
||||
import { ZTeamUrlSchema } from '@documenso/trpc/server/team-router/schema';
|
||||
import type { ActionFunctionArgs } from 'react-router';
|
||||
|
||||
/**
|
||||
* Sets the preferred team cookie.
|
||||
*/
|
||||
export const action = async ({ request }: ActionFunctionArgs) => {
|
||||
const formData = await request.formData();
|
||||
const teamUrl = ZTeamUrlSchema.safeParse(formData.get('teamUrl'));
|
||||
|
||||
if (!teamUrl.success) {
|
||||
throw new Response('Invalid team url', { status: 400 });
|
||||
}
|
||||
|
||||
return new Response('OK', {
|
||||
status: 200,
|
||||
// Attributes must stay in step with the middleware: session cookie, root path, Lax.
|
||||
headers: { 'Set-Cookie': `${PREFERRED_TEAM_URL_COOKIE}=${teamUrl.data}; Path=/; SameSite=Lax` },
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user