Restructure the process of changing a password

+ Requests are now dispatched to the according user ressource, not the collection
+ The current user can be referenced by setting the pid to 'current'
+ Refactored the error logic
This commit is contained in:
Stephan
2022-01-02 16:49:01 +01:00
parent cc1c394dce
commit 4d23eccba6
3 changed files with 88 additions and 57 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
import express from "express";
import { getAllAdmins, createAdmin, updatePassword } from "../Controllers/admin.controller";
import { getAllAdmins, createAdmin, updateOwnPassword, updateForeignPassword } from "../Controllers/admin.controller";
import { requireAuthentication } from "../Middleware/auth/auth";
const router = express.Router();
@@ -8,7 +8,7 @@ router.get("/", requireAuthentication, getAllAdmins);
router.post("/", requireAuthentication, createAdmin);
// TODO: Use URL parameters to specify the user to update
router.put("/password", requireAuthentication, updatePassword);
router.put("/current/password", requireAuthentication, updateOwnPassword);
router.put<"/:pid/password", { pid: string }>("/:pid/password", requireAuthentication, updateForeignPassword);
export default router;