list logged on shares

This commit is contained in:
ville rantanen
2018-01-25 22:42:12 +02:00
parent 938f688693
commit 7255b8481d
5 changed files with 26 additions and 14 deletions

View File

@@ -1,6 +1,9 @@
# FLEES
a very small file sharing website
A very small file sharing website.
The name comes from mispronouncing "files" very badly.
- configure shares with data/shares.json
- generate shares with utils/create-share.py

View File

@@ -32,11 +32,17 @@ def index():
for share in g.shares:
public = get_or_none(share,'public')
expired = is_expired(share)
if public and not expired:
authenticated_share = get_share(share['name'])
password_set = False
if authenticated_share[0]:
password_set = authenticated_share[1]['authenticated'] in ('hash', 'plain')
if not expired:
if public or password_set:
public_shares.append({
'name': share['name'],
'expire': get_or_none(share,'expire'),
'upload': get_or_none(share,'upload')
'upload': get_or_none(share,'upload'),
'password_set': password_set
})
return render_template("index.html", entries=public_shares)
@@ -194,18 +200,18 @@ def get_share(name, require_auth = True):
share = share[0]
if is_expired(share):
return (False, 'Share has expired')
authenticated = True
authenticated = "no-pass"
if require_auth:
if 'pass_plain' in share:
authenticated = False
if name in session:
if session[name] == hashlib.sha1(share['pass_plain'].encode('utf-8')).hexdigest():
authenticated = True
authenticated = "plain"
if 'pass_hash' in share:
authenticated = False
if name in session:
if session[name] == share['pass_hash']:
authenticated = True
authenticated = "hash"
if not authenticated:
return (False,redirect(url_for('authenticate',name=name)))
@@ -215,7 +221,8 @@ def get_share(name, require_auth = True):
"path": os.path.join(
app.config['UPLOAD_FOLDER'],
share['path']
)
),
"authenticated": authenticated
})
if not os.path.exists(share['path']):
os.makedirs(share['path'])

View File

@@ -18,6 +18,7 @@
{% for entry in entries %}
<tr>
<td><a href="{{ url_for('list_view',name=entry.name) }}">{{ entry.name }}</a>
{% if entry.password_set %}(Logged in){% endif %}
<td class=td_right>{% if entry.expire %}{{ entry.expire|safe }}{% else %}-{% endif %}
<td class=td_right>{% if entry.upload %}yes{% else %}no{% endif %}
{% endfor %}

View File

@@ -1,4 +1,5 @@
{% extends "layout.html" %}
{% block body %}
You are logged out from <a href="{{ url_for('list_view',name=name) }}">{{ name|safe }}</a>
<p>You are logged out from <a href="{{ url_for('list_view',name=name) }}">{{ name|safe }}</a></p>
<p>Continue to <a href="{{ url_for('index') }}">index</a></p>
{% endblock %}

View File

@@ -9,7 +9,7 @@ services:
- "${FLEES_EXPOSE}:80"
volumes:
- ./data/:/code/data/
restart: always
restart: unless-stopped