diff --git a/__init__.py b/__init__.py index 87d146e..11b24dd 100644 --- a/__init__.py +++ b/__init__.py @@ -23,12 +23,19 @@ def create_app(): def load_user(user_id): # using the user id as primary key as id for session return User.query.get(int(user_id)) - + + @login_required @app.route("/") def index(): passwordlist = PasswordManager.query.all() return render_template('index.html', passwordlist=passwordlist) + @app.route("/Home") + def home_page(): + passwordlist = PasswordManager.query.all() + return render_template('home.html', passwordlist=passwordlist) + + @login_required @app.route("/add",methods=["GET","POST"]) def add_password(): if request.method == 'POST': @@ -41,7 +48,7 @@ def add_password(): flash("Password Added") return redirect('/') - + @login_required @app.route('/delete/') def delete(id): new_password_to_delete = PasswordManager.query.get_or_404(id) diff --git a/auth.py b/auth.py index b9956e6..c117da2 100644 --- a/auth.py +++ b/auth.py @@ -1,8 +1,10 @@ -from flask import Blueprint,render_template,url_for,redirect,request +from flask import Blueprint,render_template,url_for,redirect,request,flash from .models import User from .extensions import db + +# Essentials For Login Creation from werkzeug.security import generate_password_hash,check_password_hash -from flask_login import login_user +from flask_login import login_user, login_required, logout_user auth = Blueprint("auth",__name__) @@ -15,10 +17,12 @@ def login(): @auth.route("/login",methods=["POST"]) def login_post(): if request.method == "POST": + # Get values from Form email = request.form.get("email") name = request.form.get("name") password = request.form.get("password") remember = request.form.get("remember") + # if it returns a user then email already exist and user exist hence check for password user = User.query.filter_by(email=email).first() @@ -37,9 +41,11 @@ def signup(): @auth.route("/signup",methods=["POST"]) def signup_post(): + # Get values from form email = request.form.get("email") name = request.form.get("name") password = request.form.get("password") + # if it returns a user then email already exist hence redirect user = User.query.filter_by(email=email).first() if user: @@ -56,9 +62,11 @@ def signup_post(): return redirect(url_for("auth.login")) -@auth.route("/logout") +@auth.route('/logout') +@login_required def logout(): - return "Login" + logout_user() + return redirect(url_for('home_page')) diff --git a/data2.db b/data2.db index 771cdc8..7d764f8 100644 Binary files a/data2.db and b/data2.db differ diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..2d3d0eb --- /dev/null +++ b/templates/base.html @@ -0,0 +1,54 @@ + + + + + + + Password Master + + + + + + +
+ {% block content %} + {% endblock %} +
+ + + + + + + \ No newline at end of file diff --git a/templates/home.html b/templates/home.html new file mode 100644 index 0000000..e09a6c7 --- /dev/null +++ b/templates/home.html @@ -0,0 +1,33 @@ +{% extends "base.html" %} + +{% block content %} +
+

Password Manager

+
+ +
+ +
+ +
+

+

+
+ +
+ + + +
+ +
+ +{% endblock %} \ No newline at end of file diff --git a/templates/index.html b/templates/index.html index aa463a8..3470c39 100644 --- a/templates/index.html +++ b/templates/index.html @@ -1,15 +1,6 @@ - - - - - - - Password Master - +{% extends "base.html" %} - - - +{% block content %}

Password Manager

@@ -97,7 +88,4 @@

Password Register

} } - - - - \ No newline at end of file +{% endblock %} \ No newline at end of file diff --git a/templates/login.html b/templates/login.html index ac3e7e2..a0fddc5 100644 --- a/templates/login.html +++ b/templates/login.html @@ -1,11 +1,7 @@ - - - - - - Password Manager - - +{% extends "base.html" %} + +{% block content %} +
@@ -14,13 +10,17 @@

+ {% with messages = get_flashed_messages() %} -{% if messages %} -
- {{ messages[0] }} -
-{% endif %} -{% endwith %} + {% if messages %} +
+ {{ messages[0] }} +
+ {% endif %} + {% endwith %} + + +

Login

@@ -40,10 +40,10 @@

Login

- +

- + @@ -51,5 +51,4 @@

Login

- - \ No newline at end of file +{% endblock %} \ No newline at end of file diff --git a/templates/old_files/index.html b/templates/old_files/index.html new file mode 100644 index 0000000..aa463a8 --- /dev/null +++ b/templates/old_files/index.html @@ -0,0 +1,103 @@ + + + + + + + Password Master + + + + + +
+

Password Manager

+
+ +
+ +
+ +
+

+

+
+ +
+

Password Register

+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ +
+ + +
+ +
+ + + +
+ + + + + + + + + + + + + + {% for task in passwordlist %} + + + + + + + + + {% endfor %} +
EmailSite AddressSite PasswordActionsVisibility
{{ task.email }}{{ task.site_url }} + Delete +
+ Update +
+ Show Password +
+
+ +
+ + + + + + \ No newline at end of file diff --git a/templates/old_files/login.html b/templates/old_files/login.html new file mode 100644 index 0000000..c3394f2 --- /dev/null +++ b/templates/old_files/login.html @@ -0,0 +1,55 @@ + + + + + + Password Manager + + +
+ +
+ +
+

+

+
+ {% with messages = get_flashed_messages() %} + {% if messages %} +
+ {{ messages[0] }} +
+ {% endif %} + {% endwith %} + +
+

Login

+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+ +
+
+ +
+ + +
+ +
+ + + \ No newline at end of file diff --git a/templates/signup.html b/templates/signup.html index ab7f754..8058cf0 100644 --- a/templates/signup.html +++ b/templates/signup.html @@ -1,10 +1,7 @@ - - - - - Password Manager - +{% extends "base.html" %} + +{% block content %}
@@ -47,5 +44,4 @@

Sign Up

- - \ No newline at end of file +{% endblock %} \ No newline at end of file