implemented deactivated services banner
Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
@@ -14,7 +14,7 @@ const pool = mysql
|
||||
export const loginFunc = async (username, password) => {
|
||||
const [result] = await pool.query(
|
||||
"SELECT * FROM users WHERE username = ? AND password = ?",
|
||||
[username, password]
|
||||
[username, password],
|
||||
);
|
||||
if (result.length > 0) return { success: true, data: result[0] };
|
||||
return { success: false };
|
||||
@@ -40,7 +40,7 @@ export const changePassword = async (username, oldPassword, newPassword) => {
|
||||
// get user current password
|
||||
const [user] = await pool.query(
|
||||
"SELECT * FROM users WHERE username = ? AND password = ?",
|
||||
[username, oldPassword]
|
||||
[username, oldPassword],
|
||||
);
|
||||
if (user.length === 0) return { success: false };
|
||||
|
||||
@@ -48,8 +48,16 @@ export const changePassword = async (username, oldPassword, newPassword) => {
|
||||
|
||||
const [result] = await pool.query(
|
||||
"UPDATE users SET password = ? WHERE username = ?",
|
||||
[newPassword, username]
|
||||
[newPassword, username],
|
||||
);
|
||||
if (result.affectedRows > 0) return { success: true };
|
||||
return { success: false };
|
||||
};
|
||||
|
||||
export const getDeactivatedServices = async () => {
|
||||
const [rows] = await pool.query("SELECT function_name FROM functions WHERE active = 0;");
|
||||
if (rows.length > 0) {
|
||||
return { success: true, data: rows };
|
||||
}
|
||||
return { success: false };
|
||||
};
|
||||
|
||||
@@ -9,7 +9,11 @@ const user_frontend_service = "User Frontend";
|
||||
const contact_form_service = "Contact Form Service";
|
||||
|
||||
// database funcs import
|
||||
import { loginFunc, changePassword } from "./database/userMgmt.database.js";
|
||||
import {
|
||||
loginFunc,
|
||||
changePassword,
|
||||
getDeactivatedServices,
|
||||
} from "./database/userMgmt.database.js";
|
||||
import { sendMail } from "./services/mailer_v2.js";
|
||||
|
||||
router.post(
|
||||
@@ -63,4 +67,13 @@ router.post(
|
||||
},
|
||||
);
|
||||
|
||||
router.get("/deactivated-services", authenticate, async (req, res) => {
|
||||
const result = await getDeactivatedServices();
|
||||
if (result.success) {
|
||||
res.status(200).json(result.data);
|
||||
} else {
|
||||
res.status(500).json({ message: "Failed to fetch deactivated services" });
|
||||
}
|
||||
});
|
||||
|
||||
export default router;
|
||||
|
||||
Reference in New Issue
Block a user