mirror of
https://github.com/outline/outline.git
synced 2026-11-21 21:44:30 +03:00
20 lines
465 B
TypeScript
20 lines
465 B
TypeScript
import { CSRF } from "@shared/constants";
|
|
import { useCsrfToken } from "~/hooks/useCsrfToken";
|
|
|
|
/**
|
|
* Form component that automatically includes a CSRF token as a hidden input field.
|
|
*/
|
|
export const Form = ({
|
|
children,
|
|
...props
|
|
}: React.FormHTMLAttributes<HTMLFormElement>) => {
|
|
const token = useCsrfToken();
|
|
|
|
return (
|
|
<form {...props}>
|
|
{token && <input type="hidden" name={CSRF.fieldName} value={token} />}
|
|
{children}
|
|
</form>
|
|
);
|
|
};
|