Save password as md5

This commit is contained in:
Ruud
2011-12-18 12:09:13 +01:00
parent 62f3121b46
commit e891287d3e
4 changed files with 19 additions and 5 deletions
+6 -1
View File
@@ -2,7 +2,7 @@ from couchpotato import app
from couchpotato.api import addApiView
from couchpotato.core.event import fireEvent, addEvent
from couchpotato.core.helpers.request import jsonified
from couchpotato.core.helpers.variable import cleanHost
from couchpotato.core.helpers.variable import cleanHost, md5
from couchpotato.core.logger import CPLog
from couchpotato.core.plugins.base import Plugin
from couchpotato.environment import Env
@@ -28,8 +28,13 @@ class Core(Plugin):
addEvent('app.load', self.launchBrowser, priority = 100)
addEvent('app.base_url', self.createBaseUrl)
addEvent('setting.save.core.password', self.md5Password)
self.removeRestartFile()
def md5Password(self, value):
return md5(value)
def available(self):
return jsonified({
'succes': True
+2 -1
View File
@@ -1,3 +1,4 @@
from couchpotato.core.helpers.variable import md5
from couchpotato.environment import Env
from flask import request, Response
from functools import wraps
@@ -16,7 +17,7 @@ def requires_auth(f):
@wraps(f)
def decorated(*args, **kwargs):
auth = getattr(request, 'authorization')
if Env.setting('username') and (not auth or not check_auth(auth.username, auth.password)):
if Env.setting('username') and (not auth or not check_auth(auth.username, md5(auth.password))):
return authenticate()
return f(*args, **kwargs)
+5 -2
View File
@@ -1,5 +1,5 @@
from couchpotato.api import addApiView
from couchpotato.core.event import addEvent
from couchpotato.core.event import addEvent, fireEvent
from couchpotato.core.helpers.encoding import isInt, toUnicode
from couchpotato.core.helpers.request import getParams, jsonified
from couchpotato.core.helpers.variable import mergeDicts
@@ -137,7 +137,10 @@ class Settings():
option = params.get('name')
value = params.get('value')
self.set(section, option, value)
# See if a value handler is attached, use that as value
new_value = fireEvent('setting.save.%s.%s' % (section, option), value, single = True)
self.set(section, option, new_value if new_value else value)
self.save()
return jsonified({
+6 -1
View File
@@ -205,7 +205,7 @@ var OptionBase = new Class({
self.section = section;
self.name = name;
self.value = value;
self.value = self.previous_value = value;
self.createBase();
self.create();
@@ -414,6 +414,11 @@ Option.Password = new Class({
self.parent()
self.input.set('type', 'password')
self.input.addEvent('focus', function(){
self.input.set('value', '')
})
}
});