From 3cfdfa3b12660a2e61801771e06f55348c7cf970 Mon Sep 17 00:00:00 2001 From: Daniel GarcĂ­a Moreno Date: Tue, 1 Jun 2021 11:43:02 +0200 Subject: Redirect to login page by default This patch redirects to the login page instead of showing an empty page when the user is not logged in. --- ogcp/views.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/ogcp/views.py b/ogcp/views.py index d49391f..9865e0f 100644 --- a/ogcp/views.py +++ b/ogcp/views.py @@ -128,18 +128,18 @@ def image_modified_date_from_str(image): @app.route('/') def index(): - clients = None - if current_user.is_authenticated: - clients = get_clients() - images_response = g.server.get('/images') - images = images_response.json()['images'] - images.sort(key=image_modified_date_from_str, reverse=True) - disk = images_response.json()['disk'] - oglive_list = g.server.get('/oglive/list').json() - return render_template('dashboard.html', clients=clients, - images=images, disk=disk, - oglive_list=oglive_list) - return render_template('base.html') + if not current_user.is_authenticated: + return redirect(url_for('login')) + + clients = get_clients() + images_response = g.server.get('/images') + images = images_response.json()['images'] + images.sort(key=image_modified_date_from_str, reverse=True) + disk = images_response.json()['disk'] + oglive_list = g.server.get('/oglive/list').json() + return render_template('dashboard.html', clients=clients, + images=images, disk=disk, + oglive_list=oglive_list) @app.route('/login', methods=['GET', 'POST']) def login(): -- cgit v1.2.3-18-g5258