diff --git a/src/controllers/Routes.ts b/src/controllers/Routes.ts index 2f7fc12..88dbd42 100644 --- a/src/controllers/Routes.ts +++ b/src/controllers/Routes.ts @@ -148,6 +148,8 @@ export const Routes : Route[] = [ // Virtual directory controller + {path: "/user/findbyfolder", cb: (h) => VirtualDirectoryController.FindUser(h)}, + {path: "/virtualDirectory/find", cb: (h) => VirtualDirectoryController.Find(h)}, ] \ No newline at end of file diff --git a/src/controllers/VirtualDirectoryController.ts b/src/controllers/VirtualDirectoryController.ts index ad4feae..d94b8c4 100644 --- a/src/controllers/VirtualDirectoryController.ts +++ b/src/controllers/VirtualDirectoryController.ts @@ -10,6 +10,24 @@ import { GroupsHelper } from "../helpers/GroupsHelper"; export class VirtualDirectoryController { + /** + * Find a user by its virtual directory + * + * @param h Request handler + */ + public static async FindUser(h: RequestHandler) { + const virtualDirectory = h.postVirtualDirectory("subfolder"); + + const userID = await UserHelper.FindByFolder(virtualDirectory); + + if(userID < 1) + h.error(404, "No user was found with this subfolder!"); + + h.send({ + userID: userID + }); + } + /** * Find a group / user using a given virtual directory *