Changed types

This commit is contained in:
2025-09-12 19:40:53 +02:00
parent af1bf82c75
commit 0fe16ad79e
12 changed files with 35 additions and 11 deletions

View File

@@ -31,6 +31,7 @@ export default async function authRoutes(server: FastifyInstance) {
const body = req.body as { email: string; password: string };
if (!body.email || !body.password) {
// @ts-ignore
return reply.code(400).send({ error: "Email and password required" });
}
@@ -45,6 +46,7 @@ export default async function authRoutes(server: FastifyInstance) {
.single();
if (error) {
// @ts-ignore
return reply.code(400).send({ error: error.message });
}
@@ -77,6 +79,7 @@ export default async function authRoutes(server: FastifyInstance) {
const body = req.body as { email: string; password: string };
if (!body.email || !body.password) {
// @ts-ignore
return reply.code(400).send({ error: "Email and password required" });
}
@@ -104,6 +107,7 @@ export default async function authRoutes(server: FastifyInstance) {
user = (data || []).find(i => i.tenants.find(x => x.id === req.tenant.id))
console.log(user)
if(error) {
// @ts-ignore
return reply.code(500).send({ error: "Internal Server Error" });
}
} else {
@@ -116,11 +120,13 @@ export default async function authRoutes(server: FastifyInstance) {
user = data
if(error) {
console.log(error);
// @ts-ignore
return reply.code(500).send({ error: "Internal Server Error" });
}
}
if(!user) {
// @ts-ignore
return reply.code(401).send({ error: "Invalid credentials" });
} else {
@@ -129,6 +135,7 @@ export default async function authRoutes(server: FastifyInstance) {
const valid = await bcrypt.compare(body.password, user.password_hash);
if (!valid) {
// @ts-ignore
return reply.code(401).send({ error: "Invalid credentials" });
} else {
const token = jwt.sign(