From d8ce50a8979c42048edb49ae4294e970ecafe3b4 Mon Sep 17 00:00:00 2001 From: cami Date: Sun, 27 Jun 2021 00:29:29 +0200 Subject: [PATCH] Formatting some things --- backend/src/app.py | 19 ++++++++++--------- frontend/src/components/Navbar.js | 15 ++++++--------- 2 files changed, 16 insertions(+), 18 deletions(-) diff --git a/backend/src/app.py b/backend/src/app.py index 6e76a6c..c0d9f3b 100644 --- a/backend/src/app.py +++ b/backend/src/app.py @@ -75,10 +75,10 @@ with app.app_context(): db.create_all() if db.session.query(User).filter_by(username='Yasoob').count() < 1: db.session.add(User( - username='Yasoob', - password=guard.hash_password('strongpassword'), - roles='admin' - )) + username='Yasoob', + password=guard.hash_password('strongpassword'), + roles='admin' + )) db.session.commit() @@ -87,7 +87,7 @@ with app.app_context(): def home(): return {"Hello": "World"}, 200 - + @app.route('/api/login', methods=['POST']) def login(): """ @@ -104,7 +104,7 @@ def login(): ret = {'access_token': guard.encode_jwt_token(user)} return ret, 200 - + @app.route('/api/refresh', methods=['POST']) def refresh(): """ @@ -119,8 +119,8 @@ def refresh(): new_token = guard.refresh_jwt_token(old_token) ret = {'access_token': new_token} return ret, 200 - - + + @app.route('/api/protected') @flask_praetorian.auth_required def protected(): @@ -133,7 +133,8 @@ def protected(): """ return {'message': f'protected endpoint (allowed user {flask_praetorian.current_user().username})'} -@app.route('/api/register', methods=['POST']) + +@app.route('/api/register', methods=['POST']) def register(): req = flask.request.get_json(force=True) username = req.get('username', None) diff --git a/frontend/src/components/Navbar.js b/frontend/src/components/Navbar.js index a9e079b..3ef9e5e 100644 --- a/frontend/src/components/Navbar.js +++ b/frontend/src/components/Navbar.js @@ -19,28 +19,25 @@ function Navbar() { } }; + const isLoggedIn = useAuth(); + /* Shows the button after resizing the screen */ useEffect(() => { showButton(); }, []); window.addEventListener("resize", showButton); + return ( <> - {" "}