From 1b5eb57de012d0e4d95cb8d9da960d8e39392a66 Mon Sep 17 00:00:00 2001 From: Christian Mundreanu <155108015+Mundreanuc223@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:44:30 -0400 Subject: [PATCH 1/3] Create .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1cc4572 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/workspace.xml From aa439e84b304090f9a11ce1a93142895f8c7f11b Mon Sep 17 00:00:00 2001 From: Christian Mundreanu <155108015+Mundreanuc223@users.noreply.github.com> Date: Mon, 14 Oct 2024 12:49:13 -0400 Subject: [PATCH 2/3] Update .gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 1cc4572..5f99e9b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .idea/workspace.xml +.idea From 378c91eb84e5163a7833b17ff1d4d3f119679c34 Mon Sep 17 00:00:00 2001 From: yoaaronw <117215469+yoaaronw@users.noreply.github.com> Date: Tue, 15 Oct 2024 19:19:32 -0400 Subject: [PATCH 3/3] Added backend implementation of login and registration forms --- vault/src/Components/LoginForm/LoginForm.css | 6 ++ vault/src/Components/LoginForm/LoginForm.jsx | 43 +++++++++++-- vault/src/backend/README.md | 2 +- vault/src/backend/app.py | 62 ++++++++++++++++++- vault/src/backend/vault_database.db | Bin 32768 -> 45056 bytes 5 files changed, 105 insertions(+), 8 deletions(-) diff --git a/vault/src/Components/LoginForm/LoginForm.css b/vault/src/Components/LoginForm/LoginForm.css index a12de62..574f972 100644 --- a/vault/src/Components/LoginForm/LoginForm.css +++ b/vault/src/Components/LoginForm/LoginForm.css @@ -85,4 +85,10 @@ .register-link p a:hover{ text-decoration: underline; +} + +.wrapper .error-message{ + font-size: 15px; + text-align: center; + margin-top: 20px; } \ No newline at end of file diff --git a/vault/src/Components/LoginForm/LoginForm.jsx b/vault/src/Components/LoginForm/LoginForm.jsx index 73749b0..63a1ded 100644 --- a/vault/src/Components/LoginForm/LoginForm.jsx +++ b/vault/src/Components/LoginForm/LoginForm.jsx @@ -1,18 +1,50 @@ -import React from 'react'; +import React, { useState } from 'react'; import './LoginForm.css'; import { FaUser } from "react-icons/fa"; import { FaLock } from "react-icons/fa"; -const LoginForm = () =>{ + +const LoginForm = () => { + // State to store the username and password + const [username, setUsername] = useState(''); + const [password, setPassword] = useState(''); + const [errorMessage, setErrorMessage] = useState(''); + + // Function to handle form submission + const handleSubmit = async (e) => { + e.preventDefault(); // Prevents page reload or default form submission + try { + // Send a POST request to backend + const response = await fetch('http://127.0.0.1:5000/login', { + method: 'POST', + headers: { + 'Content-Type': 'application/json', + }, + body: JSON.stringify({ username, password }), // Send username and password + }); + + const data = await response.json(); + + if (response.ok) { + console.log('Login successful:', data.message); + } else { + setErrorMessage(data.message); // Show error message to the user + } + } catch (error) { + console.error('Error during login:', error); + setErrorMessage('Something went wrong. Please try again.'); + } + }; + return (