From df8b499b42628f93c078124d431cd4d337da3b84 Mon Sep 17 00:00:00 2001 From: SilverDragonOfR Date: Thu, 12 Oct 2023 02:55:27 +0530 Subject: [PATCH] feat: added Fan Poll Authentication and temporary login page --- app.py | 23 ++++++++++++++++++++++- instance/database.db | Bin 8192 -> 8192 bytes templates/login.html | 10 ++++++++++ 3 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 templates/login.html diff --git a/app.py b/app.py index c7b2fc0..bd9106f 100644 --- a/app.py +++ b/app.py @@ -1,16 +1,36 @@ from flask import render_template +from flask import redirect +from flask import url_for +from flask import request from populate import populate import config +import functools app = config.app with app.app_context(): populate(config) + +# storing the user details in session after Authentication. +session = {} + +# decorator to redirect the use to login.html page +def login_required(func): + @functools.wraps(func) + def secure_function(*args, **kwargs): + if "username" not in session: + return redirect(url_for("login", next=request.url)) + return func(*args, **kwargs) + return secure_function @app.route('/') def index(): return render_template('index.html') +@app.route('/login') +def login(): + return render_template('login.html') + @app.route('/standings') def standings(): return render_template('standings.html') @@ -20,8 +40,9 @@ def fixtures(): return render_template('fixtures.html') @app.route('/Fan_Poll') +@login_required def Fan_Poll(): - return render_template('Fan_Poll.html') + return render_template('Fan_Poll.html', username=session["username"]) if __name__ == "__main__": app.run(debug=True) diff --git a/instance/database.db b/instance/database.db index c08b1909057835591108720363d5c6bb659aeb3f..be93f0d30c341c288610a80043795f3c00e5bfb4 100644 GIT binary patch literal 8192 zcmeHKO>^5s7`7AV!%pHfe3{k=%N4GZ(hsd<$4LjKQG%N|wVlLv)0P(6ZKTv{VwsWU zmY!f3W;nv1pv*7>7mmzu;0TwV8BY8LIB;Nw-PNwNN|ct&(3?H>SeC8F@B4hbyJ~J# zO~(*-yLJaUq8d37iAEz!q8N!pZlKo?da=hCI*73k=sn6EA9Z*ma^b<#Dg5K)9})B% zJO&I57#J`xU|_(&fPn!60|o{R3>X+NFkoQ7zzbsFvvhPUB?!^a;|{#HZ|s^MJAK>e zvG<{sMp#g?{QEsN}|IGc!@x>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qdv3^c<6d%E&>`s>O_vsu-yPqHYNy`gtyZN&B(C0m5Gx)G==~)6E0~vN}BIOKr`)= z#>M2B=9ahPq)H*PHSMl+{5GAYn~~;8(SQ%khiG$d>1{K7gSNOfj&SorN-DazL37e9 z5=ovz+tU)XEcX}u=Br|Ny^Y+=tabxM`DB)F-C>d*CMV=FluO=~c(aRv_*i;6g&DJ;4-+&A^Lfyh z42{#o_vLX&Rkw#o>jERyH!I#&V{QHA<>aOO#T6gyLN`My7V)RSUgI1^)t6 C4hU)h delta 209 zcmZp0XmFSy&8RU^#+hG(LC^UxF9QPuBi|zizDFAi3;8zR=QCkc7v|l~8_LVhbAYFq zN1A&pcRIHM*JZA1E>X_ooDH1D9Je`2In>!7Y%E;H&g3dNIZ4iqQDX8+IbTNc$=~Ht z8O0{Y%7-(GPTnf-&EzTqmKFv}3xTBt!O{W{X@0OYA6S|fEX@O!=7vaffu%XY(i~uE PcCa)XNP2UE+yX`bb*4Ig diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..ec14dd6 --- /dev/null +++ b/templates/login.html @@ -0,0 +1,10 @@ +{% extends "base.html" %} + +{% block head %} + + ICC WorldCup'23 + +{% endblock %} +{% block body %} + LOGIN PAGE +{% endblock %} \ No newline at end of file