From 75f9c9930bb0ecab800f8f64717c41d16da8a4ca Mon Sep 17 00:00:00 2001 From: Krishna Saurabh Vankadaru Date: Fri, 19 Nov 2021 11:40:05 -0500 Subject: [PATCH 01/44] Fixed #1 sign up doesnt work --- Controller/home.py | 44 ++++++++++++++++++++++++-------------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/Controller/home.py b/Controller/home.py index 6fe43b57..cd03a61a 100644 --- a/Controller/home.py +++ b/Controller/home.py @@ -4,12 +4,12 @@ from werkzeug.utils import redirect from Controller.user_controller import User from Controller.application_controller import Application + home_route = Blueprint('home_route', __name__) user = User() application = Application() - upcoming_events = [ {"duedate": "28th Sept, 2021", "company": "Apple" @@ -37,55 +37,57 @@ @home_route.route('/', methods=['GET', 'POST']) @home_route.route('/login', methods=['GET', 'POST']) def login(): - return render_template('login.html',loginError = "") + return render_template('login.html', loginError="") + @home_route.route('/loginUser', methods=['GET', 'POST']) def loginUser(): session['email'] = request.form["username"] password = request.form["password"] - result = user.get(session['email'],password) + result = user.get(session['email'], password) print(result) error = "" - if(result == 0): + if (result == 0): error = "Email does not exits. Please enter a valid email." - return render_template('login.html',loginError = error) - elif(result == 2): - error="Password incorrect." - return render_template('login.html',loginError = error) + return render_template('login.html', loginError=error) + elif (result == 2): + error = "Password incorrect." + return render_template('login.html', loginError=error) else: return render_template('home.html', data=result, upcoming_events=upcoming_events) - + @home_route.route('/signup', methods=['POST']) def signup(): - name = request.form["name"] + name = request.form["name"] session['email'] = request.form["email"] password = request.form["password"] - result = user.post(name,session['email'],password) + # result = user.post(name, session['email'], password) print(name) gender = request.form["gender"] location = request.form["location"] - result = user.post(name,session['email'],password, gender, location) - if(result == 0): + result = user.post(name, session['email'], password, gender, location) + if (result == 0): error = "This email already exists. Please try with different email" return render_template('login.html', emailError=error) + data = {} data["full_name"] = name return render_template('home.html', data=data, upcoming_events=upcoming_events) + @home_route.route('/view', methods=['GET']) # @login_required def view(): application_category = request.args.get('show') - result_data = application.get(session["email"], application_category) print(result_data) - return render_template('view_list.html', data=result_data, upcoming_events=upcoming_events) -@home_route.route("/add_new_application", methods = ["GET","POST"]) + +@home_route.route("/add_new_application", methods=["GET", "POST"]) # @login_required def add_new_application(): company_name = request.form["companyName"] @@ -98,11 +100,13 @@ def add_new_application(): security_answer = request.form["securityAnswer"] notes = request.form["notes"] date_applied = request.form["dateApplied"] - result = application.post(session['email'], company_name, location, job_profile, salary, username, password, security_question, security_answer, notes, - date_applied) - if (result==0): + result = application.post(session['email'], company_name, location, job_profile, salary, username, password, + security_question, security_answer, notes, + date_applied) + if (result == 0): error = "This job application could not be stored in the database. Please try again." return render_template('home.html', jobAddError=error) + data = {} return render_template('home.html', data=data, upcoming_events=upcoming_events) @@ -113,4 +117,4 @@ def logout(): return redirect("/login") # if __name__ == '__main__': -# app.run(debug=True) \ No newline at end of file +# app.run(debug=True) From 274c90c7892d4ab1b28f110a31d9f6926068bc8a Mon Sep 17 00:00:00 2001 From: Rohan Prabhune <51504486+rhnprabhune@users.noreply.github.com> Date: Tue, 23 Nov 2021 17:26:37 -0500 Subject: [PATCH 02/44] Fixed the navigation bar issue --- Controller/home.py | 8 +++++++- Controller/user_controller.py | 4 ++++ DAO/user_dao.py | 11 +++++++++++ main.py | 1 + templates/layout/base.html | 2 +- 5 files changed, 24 insertions(+), 2 deletions(-) diff --git a/Controller/home.py b/Controller/home.py index cd03a61a..c2c987d3 100644 --- a/Controller/home.py +++ b/Controller/home.py @@ -40,12 +40,18 @@ def login(): return render_template('login.html', loginError="") +@home_route.route('/auth', methods=['GET']) +def auth(): + result = user.get_auth_user_dao(session['email']) + return render_template('home.html', data=result, upcoming_events=upcoming_events) + + @home_route.route('/loginUser', methods=['GET', 'POST']) def loginUser(): session['email'] = request.form["username"] password = request.form["password"] result = user.get(session['email'], password) - print(result) + # print(result) error = "" if (result == 0): error = "Email does not exits. Please enter a valid email." diff --git a/Controller/user_controller.py b/Controller/user_controller.py index 22c151db..b0243967 100644 --- a/Controller/user_controller.py +++ b/Controller/user_controller.py @@ -15,6 +15,10 @@ def __init__(self): def get(self,email,password): return self.user.get_user(email,password) + #@auth + def get_auth_user_dao(self, email): + return self.user.get_auth_user(email) + #@login_required def post(self, name, email,password,gender,location): return self.user.create_user(name,email,password,gender,location) diff --git a/DAO/user_dao.py b/DAO/user_dao.py index 7007efaf..e9c5f4f1 100644 --- a/DAO/user_dao.py +++ b/DAO/user_dao.py @@ -23,6 +23,17 @@ def get_user(self, email, password): else: return 2 + def get_auth_user(self, email): + data = {} + result = self.__db.run_query("SELECT count(*),user_id,email,full_name,gender,location FROM user WHERE email='"+email+"'") + if(result[0][0]==0): + return 0 + if(email == result[0][2]): + data["full_name"] = str(result[0][3]) + data["gender"] = str(result[0][4]) + data["location"] = str(result[0][5]) + return data + def get_user_id(self, email): pass diff --git a/main.py b/main.py index 39aa1c68..b9f21d05 100644 --- a/main.py +++ b/main.py @@ -16,6 +16,7 @@ api.add_resource(Application, '/application') app.register_blueprint(home_route, url_prefix='/login') app.register_blueprint(home_route, url_prefix='/') +app.register_blueprint(home_route, url_prefix='/auth') app.app_context().push() diff --git a/templates/layout/base.html b/templates/layout/base.html index c20a76c6..e5bd672f 100644 --- a/templates/layout/base.html +++ b/templates/layout/base.html @@ -31,7 +31,7 @@