completed userDataMgmt
This commit is contained in:
@@ -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 });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user