USERS_LDAP,KERNEL: small fix for login and add new module for users ldap
bzr revid: ced-1f5bf0edd1ca5dc74db7b94f36063f74a0569fe7
This commit is contained in:
parent
7cb887d4da
commit
4b060b8aff
|
@ -34,13 +34,13 @@ _uid_cache = {}
|
||||||
|
|
||||||
def login(db, login, password):
|
def login(db, login, password):
|
||||||
cr = pooler.get_db(db).cursor()
|
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()
|
res = cr.fetchone()
|
||||||
cr.close()
|
cr.close()
|
||||||
if res:
|
if res:
|
||||||
return res[0]
|
return res[0]
|
||||||
else:
|
else:
|
||||||
raise Exception('Bad username or password')
|
return False
|
||||||
|
|
||||||
def check_super(passwd):
|
def check_super(passwd):
|
||||||
if passwd == tools.config['admin_passwd']:
|
if passwd == tools.config['admin_passwd']:
|
||||||
|
|
|
@ -285,16 +285,11 @@ class common(netsvc.Service):
|
||||||
return res
|
return res
|
||||||
|
|
||||||
def login(self, db, login, password):
|
def login(self, db, login, password):
|
||||||
|
res = security.login(db, login, password)
|
||||||
logger = netsvc.Logger()
|
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'
|
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))
|
logger.notifyChannel("web-service", netsvc.LOG_INFO, "%s from '%s' using database '%s'" % (msg, login, db))
|
||||||
cr.close()
|
return res or False
|
||||||
return (res and res[0]) or False
|
|
||||||
|
|
||||||
def about(self):
|
def about(self):
|
||||||
return tools.version_string + _('''
|
return tools.version_string + _('''
|
||||||
|
|
Loading…
Reference in New Issue