diff --git a/README.md b/README.md index 6170aea..eb9d4c0 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/code/app.py b/code/app.py index 8e04f5d..c630000 100644 --- a/code/app.py +++ b/code/app.py @@ -32,12 +32,18 @@ def index(): for share in g.shares: public = get_or_none(share,'public') expired = is_expired(share) - if public and not expired: - public_shares.append({ - 'name': share['name'], - 'expire': get_or_none(share,'expire'), - 'upload': get_or_none(share,'upload') - }) + 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'), + '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']) diff --git a/code/templates/index.html b/code/templates/index.html index 50bcd1a..59ecd9d 100755 --- a/code/templates/index.html +++ b/code/templates/index.html @@ -3,7 +3,7 @@

Flees

-
@@ -18,6 +18,7 @@ {% for entry in entries %} {{ entry.name }} + {% if entry.password_set %}(Logged in){% endif %} {% if entry.expire %}{{ entry.expire|safe }}{% else %}-{% endif %} {% if entry.upload %}yes{% else %}no{% endif %} {% endfor %} diff --git a/code/templates/logout.html b/code/templates/logout.html index ce3fd4f..cf20c31 100644 --- a/code/templates/logout.html +++ b/code/templates/logout.html @@ -1,4 +1,5 @@ {% extends "layout.html" %} {% block body %} - You are logged out from {{ name|safe }} +

You are logged out from {{ name|safe }}

+

Continue to index

{% endblock %} diff --git a/docker-compose.yaml b/docker-compose.yaml index a42aa1f..61daecc 100644 --- a/docker-compose.yaml +++ b/docker-compose.yaml @@ -9,7 +9,7 @@ services: - "${FLEES_EXPOSE}:80" volumes: - ./data/:/code/data/ - restart: always + restart: unless-stopped