completed userDataMgmt

This commit is contained in:
2025-11-08 16:59:07 +01:00
parent 20d22d6ce4
commit 12277abb9e
7 changed files with 240 additions and 5 deletions

View File

@@ -1,22 +1,22 @@
import express from "express";
import { authenticate, generateToken } from "../services/tokenService.js";
import { authenticate, generateToken } from "../../services/authentication.js";
const router = express.Router();
import nodemailer from "nodemailer";
import dotenv from "dotenv";
dotenv.config();
// database funcs import
import { loginFunc } from "./database/userMgmt.database.js";
import { loginAdmin } from "./database/userMgmt.database.js";
router.post("/login", async (req, res) => {
const result = await loginFunc(req.body.username, req.body.password);
const result = await loginAdmin(req.body.username, req.body.password);
if (result.success) {
const token = await generateToken({
username: result.data.username,
first_name: result.data.first_name,
last_name: result.data.last_name,
role: result.data.role,
admin: result.data.is_admin,
});
return res.status(200).json({ message: "Login erfolgreich", token });
}