login complete (fr)

This commit is contained in:
2026-01-15 01:35:44 +00:00
parent 6746925a05
commit 1a7e3bb02c
6 changed files with 102 additions and 25 deletions

View File

@@ -5,7 +5,7 @@ export default defineEventHandler(async (event) => {
if ( !body.email || !body.password )
throw createError({ statusCode: 400, message: "Bad form. Use e-mail and password" })
console.log(body)
const req = await fetch(conf.fastapi_url + "/login",
{
method: "POST",
@@ -13,11 +13,27 @@ export default defineEventHandler(async (event) => {
"Content-Type": "application/json",
},
body: JSON.stringify({
email: body.email!,
pwd: body.password!,
email: body.email,
password: body.password,
})
}
)
if (!req.ok) throw createError({ statusCode: req.status })
else {
const body = await req.json();
await setUserSession(event,{
user: {
name: body.first_name,
surname: body.last_name,
email: body.email
},
private: {
user_id: body.id
}
})
return;
}
})