Commit c606dded authored by Daniele Venzano's avatar Daniele Venzano
Browse files

Fix redirection bug when user cookie is wrong or unset

parent 8d6e6575
__version__ = '0.8.1'
__version__ = '0.8.2'
......@@ -5,9 +5,9 @@ from zoe_client import ZoeClient
def check_user(zoeclient: ZoeClient):
if 'user_id' not in session:
return redirect(url_for('web_bp.index'))
return None
user = zoeclient.user_get(session['user_id'])
if user is None:
return redirect(url_for('web_bp.index'))
return None
else:
return user
......@@ -5,3 +5,10 @@ web_bp = Blueprint('web', __name__, template_folder='templates', static_folder='
import zoe_web.web.start
import zoe_web.web.status
import zoe_web.web.applications
from common.version import __version__
@web_bp.context_processor
def inject_version():
return dict(zoe_version=__version__)
from flask import render_template
from flask import render_template, url_for, redirect
from zoe_client import ZoeClient
from common.configuration import ipcconf
......@@ -10,6 +10,8 @@ import zoe_web.utils as web_utils
def application_new():
client = ZoeClient(ipcconf['server'], ipcconf['port'])
user = web_utils.check_user(client)
if user is None:
return redirect(url_for('web.index'))
template_vars = {
"user_id": user.id,
......@@ -22,6 +24,8 @@ def application_new():
def execution_new(app_id):
client = ZoeClient(ipcconf['server'], ipcconf['port'])
user = web_utils.check_user(client)
if user is None:
return redirect(url_for('web.index'))
application = client.application_get(app_id)
template_vars = {
......@@ -36,6 +40,8 @@ def execution_new(app_id):
def execution_terminate(exec_id):
client = ZoeClient(ipcconf['server'], ipcconf['port'])
user = web_utils.check_user(client)
if user is None:
return redirect(url_for('web.index'))
execution = client.execution_get(exec_id)
template_vars = {
......@@ -50,6 +56,8 @@ def execution_terminate(exec_id):
def application_delete(app_id):
client = ZoeClient(ipcconf['server'], ipcconf['port'])
user = web_utils.check_user(client)
if user is None:
return redirect(url_for('web.index'))
application = client.application_get(app_id)
template_vars = {
......@@ -64,6 +72,8 @@ def application_delete(app_id):
def execution_inspect(execution_id):
client = ZoeClient(ipcconf['server'], ipcconf['port'])
user = web_utils.check_user(client)
if user is None:
return redirect(url_for('web.index'))
execution = client.execution_get(execution_id)
template_vars = {
......
from flask import render_template
from flask import render_template, redirect, url_for
from zoe_client import ZoeClient
from common.configuration import ipcconf
......@@ -16,6 +16,8 @@ def index():
def home():
client = ZoeClient(ipcconf['server'], ipcconf['port'])
user = web_utils.check_user(client)
if user is None:
return redirect(url_for('web.index'))
apps = client.application_list(user.id)
template_vars = {
"user_id": user.id,
......
from flask import render_template
from flask import render_template, redirect, url_for
from zoe_client import ZoeClient
from common.configuration import ipcconf
......@@ -10,6 +10,8 @@ import zoe_web.utils as web_utils
def status_platform():
client = ZoeClient(ipcconf['server'], ipcconf['port'])
user = web_utils.check_user(client)
if user is None:
return redirect(url_for('web.index'))
platform_stats = client.platform_stats()
template_vars = {
......
......@@ -37,7 +37,7 @@
{% block footer %}
<div class="status_line">
<p>
<span id="app_name"><a href="{{ url_for("web.status_platform") }}">Zoe</a></span>
<span id="app_name"><a href="{{ url_for("web.status_platform") }}">Zoe</a> v. {{ version }}</span>
<span id="status">
[<span id="num_nodes">N/A</span> swarm nodes, <span id="num_containers">N/A</span> active containers]
</span>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment