Add admin password for database creation for issue219
This commit is contained in:
1 parent
90c916df5b
commit
24c2363907
3 files changed
+8
-7
No files matched your search
@@ -4,7 +4,6 @@
|
||||
<data>
|
||||
<record model="res.user" id="user_admin">
|
||||
<field name="login">admin</field>
|
||||
<field name="password">admin</field>
|
||||
<field name="name">Administrator</field>
|
||||
<field name="signature">Administrator</field>
|
||||
<field name="action" ref="ir.act_module_config_wizard"/>
|
||||
|
||||
@@ -32,7 +32,7 @@ class DBTestCase(unittest.TestCase):
|
||||
'''
|
||||
Create database.
|
||||
'''
|
||||
SOCK.send(('db', 'create', ADMIN_PASSWORD, DB_NAME, 'en_US'))
|
||||
SOCK.send(('db', 'create', ADMIN_PASSWORD, DB_NAME, 'en_US', PASSWORD))
|
||||
res = SOCK.receive()
|
||||
self.assert_(res)
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ from trytond import tools
|
||||
import base64
|
||||
import os
|
||||
from psycopg2.extensions import ISOLATION_LEVEL_AUTOCOMMIT
|
||||
import sha
|
||||
|
||||
|
||||
class DB(Service):
|
||||
@@ -25,7 +26,7 @@ class DB(Service):
|
||||
self.export_method(self.db_exist)
|
||||
self.export_method(self.change_admin_password)
|
||||
|
||||
def create(self, password, db_name, lang):
|
||||
def create(self, password, db_name, lang, admin_password):
|
||||
security.check_super(password)
|
||||
res = False
|
||||
|
||||
@@ -56,11 +57,12 @@ class DB(Service):
|
||||
'SET language = ' \
|
||||
'(SELECT id FROM ir_lang WHERE code = %s LIMIT 1) '\
|
||||
'WHERE login <> \'root\'', (lang,))
|
||||
cursor.execute('UPDATE res_user ' \
|
||||
'SET password = %s' \
|
||||
'WHERE login = \'admin\'',
|
||||
(sha.new(admin_password).hexdigest(),))
|
||||
cursor.commit()
|
||||
cursor.execute('SELECT login, login as password, name ' \
|
||||
'FROM res_user ' \
|
||||
'WHERE login <> \'root\' ORDER BY login')
|
||||
res = cursor.dictfetchall()
|
||||
res = True
|
||||
except:
|
||||
logger.notify_channel("web-service", LOG_ERROR,
|
||||
'CREATE DB: %s failed' % (db_name,))
|
||||
|
||||
Reference in new issue
Block a user