wedding-planner-frontend/app/api/authentication.tsx
Manuel Bustillo 989820e41b
All checks were successful
Check usage of free licenses / build-static-assets (pull_request) Successful in 1m11s
Add copyright notice / copyright_notice (pull_request) Successful in 1m30s
Playwright Tests / test (pull_request) Successful in 3m38s
Add copyright notice
2024-12-01 15:33:24 +00:00

17 lines
530 B
TypeScript

/* Copyright (C) 2024 Manuel Bustillo*/
import { getCsrfToken } from '@/app/lib/utils';
export function login({ email, password, onLogin }: { email: string, password: string, onLogin: () => void }) {
console.log(email, password);
return fetch("/api/default/users/sign_in", {
method: 'POST',
body: JSON.stringify({ user: { email, password } }),
headers: {
'Content-Type': 'application/json',
'X-CSRF-TOKEN': getCsrfToken(),
}
})
.then(onLogin)
.catch((error) => console.error(error));
}