environment class

get_session
This commit is contained in:
Ruud
2011-02-23 13:57:13 +01:00
parent 80cc8abf68
commit cdde98653e
8 changed files with 78 additions and 108 deletions
+3 -3
View File
@@ -1,9 +1,9 @@
from couchpotato.core.settings import settings
from couchpotato.environment import Env
from flask import request, Response
from functools import wraps
def check_auth(username, password):
return username == settings.get('username') and password == settings.get('password')
return username == Env.get('settings').get('username') and password == Env.get('settings').get('password')
def authenticate():
return Response(
@@ -16,7 +16,7 @@ def requires_auth(f):
@wraps(f)
def decorated(*args, **kwargs):
auth = request.authorization
if settings.get('username') and (not auth or not check_auth(auth.username, auth.password)):
if Env.get('settings').get('username') and (not auth or not check_auth(auth.username, auth.password)):
return authenticate()
return f(*args, **kwargs)