From 94f5d3f85b287d8c3a4c2e9203ad216d1d3b4a1a Mon Sep 17 00:00:00 2001 From: Peter KW Date: Sun, 17 Mar 2024 10:35:48 +0100 Subject: [PATCH] Component for checking login, to be replaced with proper fetching --- frontend/src/Components/LoginCheck.tsx | 35 ++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 frontend/src/Components/LoginCheck.tsx diff --git a/frontend/src/Components/LoginCheck.tsx b/frontend/src/Components/LoginCheck.tsx new file mode 100644 index 0000000..ccf761d --- /dev/null +++ b/frontend/src/Components/LoginCheck.tsx @@ -0,0 +1,35 @@ +import { NewUser } from "../Types/Users"; + +function LoginCheck(props: { username: string; password: string }): number { + //Example users for testing without backend, remove when using backend + const admin: NewUser = { + userName: "admin", + password: "123", + }; + const pmanager: NewUser = { + userName: "pmanager", + password: "123", + }; + const user: NewUser = { + userName: "user", + password: "123", + }; + + //TODO: Compare with db instead when finished + if (props.username === admin.userName && props.password === admin.password) { + return 1; + } else if ( + props.username === pmanager.userName && + props.password === pmanager.password + ) { + return 2; + } else if ( + props.username === user.userName && + props.password === user.password + ) { + return 3; + } + return 0; +} + +export default LoginCheck;