mirror of
https://github.com/spl0k/supysonic.git
synced 2024-12-22 17:06:17 +00:00
Improved sessions handling
This commit is contained in:
parent
856e96c28d
commit
7dbd1f9764
11
web.py
11
web.py
@ -9,6 +9,7 @@ app.secret_key = '?9huDM\\H'
|
||||
|
||||
import db
|
||||
from scanner import Scanner
|
||||
from user_manager import UserManager
|
||||
|
||||
@app.before_request
|
||||
def init_and_login_check():
|
||||
@ -20,7 +21,15 @@ def init_and_login_check():
|
||||
flash('Not configured. Please create the first admin user')
|
||||
return redirect(url_for('add_user'))
|
||||
|
||||
if not (admin_count == 0 and request.endpoint == 'add_user') and not session.get('userid') and request.endpoint != 'login':
|
||||
if not (admin_count == 0 and request.endpoint == 'add_user') and request.endpoint != 'login':
|
||||
should_login = False
|
||||
if not session.get('userid'):
|
||||
should_login = True
|
||||
elif UserManager.get(session.get('userid'))[0] != UserManager.SUCCESS:
|
||||
session.clear()
|
||||
should_login = True
|
||||
|
||||
if should_login:
|
||||
flash('Please login')
|
||||
return redirect(url_for('login', returnUrl = request.url[len(request.url_root)-1:]))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user