diff options
author | Navan Chauhan <navanchauhan@gmail.com> | 2021-06-04 00:06:46 +0530 |
---|---|---|
committer | Navan Chauhan <navanchauhan@gmail.com> | 2021-06-04 00:06:46 +0530 |
commit | 63ed2bb6cf3cccf341b3afe1ffc6165b9b95ac88 (patch) | |
tree | de3f86827c36691cba2f7cf06db2a7406268f392 /app | |
parent | a3b38a5c327ba45515c75efccbd18e813c27aad0 (diff) |
added dashboard
Diffstat (limited to 'app')
-rw-r--r-- | app/templates/dashboard.html | 13 | ||||
-rw-r--r-- | app/views/auth.py | 26 |
2 files changed, 35 insertions, 4 deletions
diff --git a/app/templates/dashboard.html b/app/templates/dashboard.html new file mode 100644 index 0000000..66e8cd6 --- /dev/null +++ b/app/templates/dashboard.html @@ -0,0 +1,13 @@ +{% extends "base.html" %} +{% block title %}Home{% endblock %} +{% block head %} + {{ super() }} +{% endblock %} +{% block content %} +<div class="container"> + <h1>Hi {{user.first_name}}</h1> + <p> + Welcome to your dashboard + </p> +</div> +{% endblock %}
\ No newline at end of file diff --git a/app/views/auth.py b/app/views/auth.py index f31a4cd..6ae6ef9 100644 --- a/app/views/auth.py +++ b/app/views/auth.py @@ -1,7 +1,8 @@ -from app import app, db, models -from app.forms.app_forms import UserSignUp -from flask import render_template, flash +from app import app, db, models, login_manager +from app.forms.app_forms import UserSignUp, UserLogIn +from flask import render_template, flash,url_for, redirect from app.misc_func import flash_errors +import flask_login @app.route("/signup", methods=['GET', 'POST']) @@ -18,4 +19,21 @@ def register_user(): db.session.add(user) db.session.commit() flash_errors(form) - return render_template("auth/signup.html",form=form)
\ No newline at end of file + return render_template("auth/signup.html",form=form) + +@app.route("/login", methods=['GET', 'POST']) +def signin_user(): + form = UserLogIn() + if form.validate_on_submit(): + user = models.User.query.filter_by(email=form.email.data).first() + if user is not None: + if user.check_password(form.password.data): + flask_login.login_user(user) + return redirect(url_for("user_dashboard")) + flash_errors(form) + return render_template("auth/signin.html",form=form) + +@flask_login.login_required +@app.route("/dashboard") +def user_dashboard(): + return render_template("dashboard.html",user=flask_login.current_user) |