Tidying
This commit is contained in:
@@ -8,9 +8,6 @@ export default fp(async (server: FastifyInstance) => {
|
||||
reply.code(400).send({ error: "Missing host header" });
|
||||
return;
|
||||
}
|
||||
|
||||
console.log(host)
|
||||
|
||||
// Tenant aus DB laden
|
||||
const { data: tenant } = await server.supabase
|
||||
.from("tenants")
|
||||
|
||||
@@ -101,12 +101,8 @@ export default async function authRoutes(server: FastifyInstance) {
|
||||
.select("*, tenants!auth_tenant_users(*)")
|
||||
.eq("email", body.email)
|
||||
|
||||
console.log(data)
|
||||
console.log(error)
|
||||
|
||||
// @ts-ignore
|
||||
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" });
|
||||
@@ -120,7 +116,6 @@ export default async function authRoutes(server: FastifyInstance) {
|
||||
.single();
|
||||
user = data
|
||||
if(error) {
|
||||
console.log(error);
|
||||
// @ts-ignore
|
||||
return reply.code(500).send({ error: "Internal Server Error" });
|
||||
}
|
||||
@@ -131,18 +126,15 @@ export default async function authRoutes(server: FastifyInstance) {
|
||||
return reply.code(401).send({ error: "Invalid credentials" });
|
||||
} else {
|
||||
|
||||
console.log(user);
|
||||
console.log(body)
|
||||
|
||||
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(
|
||||
{ user_id: user.id, email: user.email, tenant_id: req.tenant ? req.tenant.id : null },
|
||||
{ user_id: user.id, email: user.email, tenant_id: req.tenant?.id ? req.tenant.id : null },
|
||||
secrets.JWT_SECRET!,
|
||||
{ expiresIn: "3h" }
|
||||
{ expiresIn: "6h" }
|
||||
);
|
||||
|
||||
reply.setCookie("token", token, {
|
||||
|
||||
@@ -64,7 +64,6 @@ export default async function meRoutes(server: FastifyInstance) {
|
||||
if(permissionsError) {
|
||||
console.log(permissionsError)
|
||||
}
|
||||
console.log(permissionsData)
|
||||
|
||||
const permissions = permissionsData.map(i => i.permission) || []
|
||||
|
||||
|
||||
@@ -22,23 +22,6 @@ export default async function fileRoutes(server: FastifyInstance) {
|
||||
|
||||
console.log(data)
|
||||
|
||||
/*const parts = req.parts() // mehrere FormData-Felder
|
||||
|
||||
console.log(parts)
|
||||
|
||||
let file: any
|
||||
let meta: any
|
||||
|
||||
for await (const part of parts) {
|
||||
//console.log(part)
|
||||
// @ts-ignore
|
||||
if (part.file) {
|
||||
file = part
|
||||
|
||||
// @ts-ignore
|
||||
meta = JSON.parse(part.fields?.meta?.value)
|
||||
}
|
||||
}*/
|
||||
|
||||
let meta = JSON.parse(data.fields?.meta?.value)
|
||||
|
||||
|
||||
@@ -543,10 +543,6 @@ export default async function resourceRoutes(server: FastifyInstance) {
|
||||
createData[dataType.numberRangeHolder] = result.usedNumber
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
const { data, error } = await server.supabase
|
||||
.from(resource)
|
||||
.insert(createData)
|
||||
|
||||
Reference in New Issue
Block a user