Properly encode before md5. fix #580

This commit is contained in:
Ruud
2012-07-14 23:23:45 +02:00
parent 7c687d4d6b
commit b3e709c6c5
3 changed files with 6 additions and 5 deletions
+3 -2
View File
@@ -17,8 +17,9 @@ def requires_auth(f):
@wraps(f)
def decorated(*args, **kwargs):
auth = getattr(request, 'authorization')
if Env.setting('username') and Env.setting('password') and (not auth or not check_auth(auth.username, md5(auth.password))):
return authenticate()
if Env.setting('username') and Env.setting('password'):
if (not auth or not check_auth(auth.username.decode('latin1'), md5(auth.password.decode('latin1').encode(Env.get('encoding'))))):
return authenticate()
return f(*args, **kwargs)