2024-12-01 15:33:24 +00:00
|
|
|
/* Copyright (C) 2024 Manuel Bustillo*/
|
|
|
|
|
2024-12-01 16:31:56 +01:00
|
|
|
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));
|
|
|
|
}
|