Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
zoe
main
Commits
c606dded
Commit
c606dded
authored
Sep 21, 2015
by
Daniele Venzano
Browse files
Fix redirection bug when user cookie is wrong or unset
parent
8d6e6575
Changes
7
Hide whitespace changes
Inline
Side-by-side
common/version.py
View file @
c606dded
__version__
=
'0.8.
1
'
__version__
=
'0.8.
2
'
zoe_web/utils.py
View file @
c606dded
...
...
@@ -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
zoe_web/web/__init__.py
View file @
c606dded
...
...
@@ -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__
)
zoe_web/web/applications.py
View file @
c606dded
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
=
{
...
...
zoe_web/web/start.py
View file @
c606dded
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
,
...
...
zoe_web/web/status.py
View file @
c606dded
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
=
{
...
...
zoe_web/web/templates/base.html
View file @
c606dded
...
...
@@ -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>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment