diff --git a/initial src-code/Backend/__pycache__/AutoPayment.cpython-311.pyc b/initial src-code/Backend/__pycache__/AutoPayment.cpython-311.pyc new file mode 100644 index 000000000..d314a3024 Binary files /dev/null and b/initial src-code/Backend/__pycache__/AutoPayment.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/BalanceAccount.cpython-311.pyc b/initial src-code/Backend/__pycache__/BalanceAccount.cpython-311.pyc new file mode 100644 index 000000000..e10998173 Binary files /dev/null and b/initial src-code/Backend/__pycache__/BalanceAccount.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/Card.cpython-311.pyc b/initial src-code/Backend/__pycache__/Card.cpython-311.pyc new file mode 100644 index 000000000..4f52ad32d Binary files /dev/null and b/initial src-code/Backend/__pycache__/Card.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/ChequingAccount.cpython-311.pyc b/initial src-code/Backend/__pycache__/ChequingAccount.cpython-311.pyc new file mode 100644 index 000000000..1c271cac5 Binary files /dev/null and b/initial src-code/Backend/__pycache__/ChequingAccount.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/ClientAccount.cpython-311.pyc b/initial src-code/Backend/__pycache__/ClientAccount.cpython-311.pyc new file mode 100644 index 000000000..573af203b Binary files /dev/null and b/initial src-code/Backend/__pycache__/ClientAccount.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/CreditAccount.cpython-311.pyc b/initial src-code/Backend/__pycache__/CreditAccount.cpython-311.pyc new file mode 100644 index 000000000..0d5cb303b Binary files /dev/null and b/initial src-code/Backend/__pycache__/CreditAccount.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/Etransfer.cpython-311.pyc b/initial src-code/Backend/__pycache__/Etransfer.cpython-311.pyc new file mode 100644 index 000000000..18dc5c248 Binary files /dev/null and b/initial src-code/Backend/__pycache__/Etransfer.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/EtransferPayee.cpython-311.pyc b/initial src-code/Backend/__pycache__/EtransferPayee.cpython-311.pyc new file mode 100644 index 000000000..2fc8edcd7 Binary files /dev/null and b/initial src-code/Backend/__pycache__/EtransferPayee.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/IDGenerator.cpython-311.pyc b/initial src-code/Backend/__pycache__/IDGenerator.cpython-311.pyc new file mode 100644 index 000000000..b837c006e Binary files /dev/null and b/initial src-code/Backend/__pycache__/IDGenerator.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/Loan.cpython-311.pyc b/initial src-code/Backend/__pycache__/Loan.cpython-311.pyc new file mode 100644 index 000000000..754a4de0f Binary files /dev/null and b/initial src-code/Backend/__pycache__/Loan.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/Payee.cpython-311.pyc b/initial src-code/Backend/__pycache__/Payee.cpython-311.pyc new file mode 100644 index 000000000..02f93322a Binary files /dev/null and b/initial src-code/Backend/__pycache__/Payee.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/SavingsAccount.cpython-311.pyc b/initial src-code/Backend/__pycache__/SavingsAccount.cpython-311.pyc new file mode 100644 index 000000000..e00e898b8 Binary files /dev/null and b/initial src-code/Backend/__pycache__/SavingsAccount.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/TellerAccount.cpython-311.pyc b/initial src-code/Backend/__pycache__/TellerAccount.cpython-311.pyc new file mode 100644 index 000000000..a7d2117bf Binary files /dev/null and b/initial src-code/Backend/__pycache__/TellerAccount.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/Transaction.cpython-311.pyc b/initial src-code/Backend/__pycache__/Transaction.cpython-311.pyc new file mode 100644 index 000000000..72fad871a Binary files /dev/null and b/initial src-code/Backend/__pycache__/Transaction.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/UserAccount.cpython-311.pyc b/initial src-code/Backend/__pycache__/UserAccount.cpython-311.pyc new file mode 100644 index 000000000..c15b7be69 Binary files /dev/null and b/initial src-code/Backend/__pycache__/UserAccount.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/cloud_database.cpython-311.pyc b/initial src-code/Backend/__pycache__/cloud_database.cpython-311.pyc new file mode 100644 index 000000000..d4fd60ecb Binary files /dev/null and b/initial src-code/Backend/__pycache__/cloud_database.cpython-311.pyc differ diff --git a/initial src-code/Backend/__pycache__/main.cpython-311.pyc b/initial src-code/Backend/__pycache__/main.cpython-311.pyc new file mode 100644 index 000000000..b2313e30e Binary files /dev/null and b/initial src-code/Backend/__pycache__/main.cpython-311.pyc differ diff --git a/initial src-code/Backend/app.py b/initial src-code/Backend/app.py index a97006255..93d889adb 100644 --- a/initial src-code/Backend/app.py +++ b/initial src-code/Backend/app.py @@ -1,20 +1,28 @@ from __future__ import annotations from flask import Flask, render_template, request -import main +from flask import Flask, request, jsonify +from flask_cors import CORS +from main import Bank +from cloud_database import Database app = Flask(__name__) - -@app.route('/') -def home(): - return render_template('login.html') +CORS(app) +connection_string = "mongodb+srv://tahshinshahriar:i2NK6Sc0jmCnhjWO@cluster0.nafiayb.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0" +db_name = "financial-data" +collection_name = "user-info-collection" +db = Database(connection_string, db_name, collection_name) +bank = Bank() #Login Page @app.route('/login', methods=['POST']) def login(): - username = request.form['xxxx'] - password = request.form['xxxx'] - + data = request.json + email = data.get('email') + password = data.get('password') + if db.get_password(email) == password: + return jsonify({'message': 'Login successful!'}), 200 + return jsonify({'message': 'Invalid credentials!'}), 401 # Teller Interface @@ -29,12 +37,7 @@ def tellerHome(): return tellerInterface(teller) -@app.route('/reg') -def register(): - return render_template('registration.html') - - -@app.route('/regp', methods=['POST']) +@app.route('/register-client', methods=['POST']) def reg(): username = request.form['username'] name = request.form['name'] @@ -42,8 +45,6 @@ def reg(): phone = request.form['phone'] addr = request.form['addr'] - clientp = teller.registerClient(username, name, email, phone, addr) - if clientp != False or None: return render_template('regsuccess.html', name=clientp.username, email=clientp.e_mail, passwd=clientp._password, phone=clientp.phone, accno=clientp._accountNumber, addr=clientp.address) else: diff --git a/initial src-code/Backend/cloud_database.py b/initial src-code/Backend/cloud_database.py new file mode 100644 index 000000000..5d0ec9341 --- /dev/null +++ b/initial src-code/Backend/cloud_database.py @@ -0,0 +1,34 @@ +from pymongo import MongoClient +import certifi + +class Database: + def __init__(self, connection_string, db_name, collection_name): + self.connection_string = connection_string + self.db_name = db_name + self.collection_name = collection_name + self.client = None + self.db = None + self.collection = None + self.connect() + + def connect(self): + self.client = MongoClient(self.connection_string, tlsCAFile=certifi.where()) + self.db = self.client[self.db_name] + self.collection = self.db[self.collection_name] + + + def get_password(self, username:str): + user_data = self.collection.find_one({"Username": username}) + if user_data: + return user_data.get("Password") + return None + + def get_userinfo(self, username:str): + user_data = self.collection.find_one({"Username": username}) + return user_data + + def insert_user(self, user_data:dict): + result = self.collection.insert_one(user_data) + return result.inserted_id + + diff --git a/initial src-code/Backend/database.py b/initial src-code/Backend/google_database.py similarity index 100% rename from initial src-code/Backend/database.py rename to initial src-code/Backend/google_database.py diff --git a/initial src-code/Backend/main.py b/initial src-code/Backend/main.py index e06bc205d..11bf19c0d 100644 --- a/initial src-code/Backend/main.py +++ b/initial src-code/Backend/main.py @@ -1,15 +1,19 @@ -import ClientAccount -import TellerAccount -import EtransferPayee -from datetime import datetime -import Payee -from database import Database +from cloud_database import Database class Bank: - database = Database('/Users/tahshin/CodeBlocks/Slack-Bot/creds.json', "Test") - sheet = database.open_worksheet('UserInfo') + def __init__(self): + connection_string = "mongodb+srv://tahshinshahriar:i2NK6Sc0jmCnhjWO@cluster0.nafiayb.mongodb.net/?retryWrites=true&w=majority&appName=Cluster0" + db_name = "financial-data" + collection_name = "user-info-collection" + db = Database(connection_string, db_name, collection_name) - # def login(self, usrname, passwd): + def login(self, email, passwd): + if self.db.get_password(email) == passwd: + return True + return False + + + diff --git a/src/pages/IntroPage/index.js b/src/pages/IntroPage/index.js index 22b62c8eb..cb20e130a 100644 --- a/src/pages/IntroPage/index.js +++ b/src/pages/IntroPage/index.js @@ -1,5 +1,5 @@ import * as React from 'react'; -import {Link, useLocation} from 'react-router-dom'; +import {Link, useLocation, useNavigate} from 'react-router-dom'; import Avatar from '@mui/material/Avatar'; import Button from '@mui/material/Button'; import CssBaseline from '@mui/material/CssBaseline'; @@ -12,6 +12,8 @@ import Typography from '@mui/material/Typography'; import { createTheme, ThemeProvider } from '@mui/material/styles'; import HeaderB from '../../components/header'; +import axios from 'axios'; + @@ -48,15 +50,24 @@ function Copyright(props) { function IntroductionPage() { const location = useLocation(); const accountCreated = location.state?.accountCreated || false; + const navigate = useNavigate(); const handleSubmit = (event) => { event.preventDefault(); const data = new FormData(event.currentTarget); - console.log({ - email: data.get('email'), - password: data.get('password'), - }); + const email = data.get('email'); + const password = data.get('password'); + + axios.post('http://localhost:5000/login', { email, password }) + .then(response => { + console.log(response.data); + navigate('/dashboard'); + }) + .catch(error => { + console.error('There was an error!', error); + // Handle error (e.g., show an error message) + }); };