USERS_LDAP,KERNEL: small fix for login and add new module for users ldap

bzr revid: ced-1f5bf0edd1ca5dc74db7b94f36063f74a0569fe7
This commit is contained in:
ced 2007-03-07 15:53:14 +00:00
parent 7cb887d4da
commit 4b060b8aff
2 changed files with 4 additions and 9 deletions

View File

@ -34,13 +34,13 @@ _uid_cache = {}
def login(db, login, password):
cr = pooler.get_db(db).cursor()
cr.execute('select id from res_users where login=%s and password=%s and active', (login, password))
cr.execute('select id from res_users where login=%s and password=%s and active', (login.encode('utf-8'), password.encode('utf-8')))
res = cr.fetchone()
cr.close()
if res:
return res[0]
else:
raise Exception('Bad username or password')
return False
def check_super(passwd):
if passwd == tools.config['admin_passwd']:

View File

@ -285,16 +285,11 @@ class common(netsvc.Service):
return res
def login(self, db, login, password):
res = security.login(db, login, password)
logger = netsvc.Logger()
cr = pooler.get_db(db).cursor()
#FIXME: this is a temporary fix for the crash on login/password with non ASCII chars.
#We should fix this in a better way (ie somewhere else)
cr.execute('select id from res_users where login=%s and password=%s', (login.encode('utf-8'), password.encode('utf-8')))
res = cr.fetchone()
msg = res and 'successful login' or 'bad login or password'
logger.notifyChannel("web-service", netsvc.LOG_INFO, "%s from '%s' using database '%s'" % (msg, login, db))
cr.close()
return (res and res[0]) or False
return res or False
def about(self):
return tools.version_string + _('''