1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
28 def login(db, login, password):
29 cr = pooler.get_db(db).cursor()
30 cr.execute('select id from res_users where login=%s and password=%s and active', (login.encode('utf-8'), password.encode('utf-8')))
38 def check_super(passwd):
39 if passwd == tools.config['admin_passwd']:
42 raise Exception('AccessDenied')
44 def check(db, uid, passwd):
45 if _uid_cache.get(db, {}).get(uid) == passwd:
47 cr = pooler.get_db(db).cursor()
48 cr.execute('select count(*) from res_users where id=%s and password=%s', (int(uid), passwd))
49 res = cr.fetchone()[0]
52 raise Exception('AccessDenied')
54 if _uid_cache.has_key(db):
55 ulist = _uid_cache[db]
58 _uid_cache[db] = {uid:passwd}
61 def access(db, uid, passwd, sec_level, ids):
62 cr = pooler.get_db(db).cursor()
63 cr.execute('select id from res_users where id=%s and password=%s', (uid, passwd))
67 raise Exception('Bad username or password')
70 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: