list logged on shares
This commit is contained in:
27
code/app.py
27
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'])
|
||||
|
||||
Reference in New Issue
Block a user