list logged on shares
This commit is contained in:
@@ -1,6 +1,9 @@
|
|||||||
# FLEES
|
# 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
|
- configure shares with data/shares.json
|
||||||
- generate shares with utils/create-share.py
|
- generate shares with utils/create-share.py
|
||||||
|
|||||||
19
code/app.py
19
code/app.py
@@ -32,11 +32,17 @@ def index():
|
|||||||
for share in g.shares:
|
for share in g.shares:
|
||||||
public = get_or_none(share,'public')
|
public = get_or_none(share,'public')
|
||||||
expired = is_expired(share)
|
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({
|
public_shares.append({
|
||||||
'name': share['name'],
|
'name': share['name'],
|
||||||
'expire': get_or_none(share,'expire'),
|
'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)
|
return render_template("index.html", entries=public_shares)
|
||||||
@@ -194,18 +200,18 @@ def get_share(name, require_auth = True):
|
|||||||
share = share[0]
|
share = share[0]
|
||||||
if is_expired(share):
|
if is_expired(share):
|
||||||
return (False, 'Share has expired')
|
return (False, 'Share has expired')
|
||||||
authenticated = True
|
authenticated = "no-pass"
|
||||||
if require_auth:
|
if require_auth:
|
||||||
if 'pass_plain' in share:
|
if 'pass_plain' in share:
|
||||||
authenticated = False
|
authenticated = False
|
||||||
if name in session:
|
if name in session:
|
||||||
if session[name] == hashlib.sha1(share['pass_plain'].encode('utf-8')).hexdigest():
|
if session[name] == hashlib.sha1(share['pass_plain'].encode('utf-8')).hexdigest():
|
||||||
authenticated = True
|
authenticated = "plain"
|
||||||
if 'pass_hash' in share:
|
if 'pass_hash' in share:
|
||||||
authenticated = False
|
authenticated = False
|
||||||
if name in session:
|
if name in session:
|
||||||
if session[name] == share['pass_hash']:
|
if session[name] == share['pass_hash']:
|
||||||
authenticated = True
|
authenticated = "hash"
|
||||||
|
|
||||||
if not authenticated:
|
if not authenticated:
|
||||||
return (False,redirect(url_for('authenticate',name=name)))
|
return (False,redirect(url_for('authenticate',name=name)))
|
||||||
@@ -215,7 +221,8 @@ def get_share(name, require_auth = True):
|
|||||||
"path": os.path.join(
|
"path": os.path.join(
|
||||||
app.config['UPLOAD_FOLDER'],
|
app.config['UPLOAD_FOLDER'],
|
||||||
share['path']
|
share['path']
|
||||||
)
|
),
|
||||||
|
"authenticated": authenticated
|
||||||
})
|
})
|
||||||
if not os.path.exists(share['path']):
|
if not os.path.exists(share['path']):
|
||||||
os.makedirs(share['path'])
|
os.makedirs(share['path'])
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
{% for entry in entries %}
|
{% for entry in entries %}
|
||||||
<tr>
|
<tr>
|
||||||
<td><a href="{{ url_for('list_view',name=entry.name) }}">{{ entry.name }}</a>
|
<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.expire %}{{ entry.expire|safe }}{% else %}-{% endif %}
|
||||||
<td class=td_right>{% if entry.upload %}yes{% else %}no{% endif %}
|
<td class=td_right>{% if entry.upload %}yes{% else %}no{% endif %}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{% extends "layout.html" %}
|
{% extends "layout.html" %}
|
||||||
{% block body %}
|
{% 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 %}
|
{% endblock %}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ services:
|
|||||||
- "${FLEES_EXPOSE}:80"
|
- "${FLEES_EXPOSE}:80"
|
||||||
volumes:
|
volumes:
|
||||||
- ./data/:/code/data/
|
- ./data/:/code/data/
|
||||||
restart: always
|
restart: unless-stopped
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user