dont create old userid
This commit is contained in:
parent
2c9109a7a5
commit
f1ba3fbd34
3 changed files with 15 additions and 15 deletions
|
@ -509,7 +509,8 @@ def update_online():
|
||||||
'id': settings.USER_ID,
|
'id': settings.USER_ID,
|
||||||
'online': state.online
|
'online': state.online
|
||||||
})
|
})
|
||||||
if not settings.server.get('migrated_id', False):
|
|
||||||
|
if settings.OLD_USER_ID and not settings.server.get('migrated_id', False):
|
||||||
r = directory.put(settings.sk, {
|
r = directory.put(settings.sk, {
|
||||||
'id': settings.USER_ID,
|
'id': settings.USER_ID,
|
||||||
})
|
})
|
||||||
|
|
|
@ -58,15 +58,13 @@ if os.path.exists(key_path):
|
||||||
with open(key_path, 'rb') as fd:
|
with open(key_path, 'rb') as fd:
|
||||||
sk = ed25519.SigningKey(fd.read())
|
sk = ed25519.SigningKey(fd.read())
|
||||||
vk = sk.get_verifying_key()
|
vk = sk.get_verifying_key()
|
||||||
|
OLD_USER_ID = vk.to_ascii(encoding='base64').decode()
|
||||||
else:
|
else:
|
||||||
sk, vk = ed25519.create_keypair()
|
sk = None
|
||||||
with open(key_path, 'wb') as fd:
|
vk = None
|
||||||
os.chmod(key_path, 0o600)
|
OLD_USER_ID = None
|
||||||
fd.write(sk.to_bytes())
|
|
||||||
os.chmod(key_path, 0o400)
|
|
||||||
|
|
||||||
USER_ID = get_user_id(ssl_key_path, ssl_cert_path)
|
USER_ID = get_user_id(ssl_key_path, ssl_cert_path)
|
||||||
OLD_USER_ID = vk.to_ascii(encoding='base64').decode()
|
|
||||||
|
|
||||||
OML_UPDATE_KEY='K55EZpPYbP3X+3mA66cztlw1sSaUMqGwfTDKQyP2qOU'
|
OML_UPDATE_KEY='K55EZpPYbP3X+3mA66cztlw1sSaUMqGwfTDKQyP2qOU'
|
||||||
|
|
||||||
|
|
17
oml/setup.py
17
oml/setup.py
|
@ -378,14 +378,15 @@ def upgrade_db(old, new=None):
|
||||||
old_key = os.path.join(settings.config_path, 'node.ssl.key')
|
old_key = os.path.join(settings.config_path, 'node.ssl.key')
|
||||||
if os.path.exists(old_key):
|
if os.path.exists(old_key):
|
||||||
os.unlink(old_key)
|
os.unlink(old_key)
|
||||||
statements = [
|
if settings.OLD_USER_ID:
|
||||||
"UPDATE user SET id = '{nid}' WHERE id = '{oid}'",
|
statements = [
|
||||||
"UPDATE list SET user_id = '{nid}' WHERE user_id = '{oid}'",
|
"UPDATE user SET id = '{nid}' WHERE id = '{oid}'",
|
||||||
"UPDATE useritem SET user_id = '{nid}' WHERE user_id = '{oid}'",
|
"UPDATE list SET user_id = '{nid}' WHERE user_id = '{oid}'",
|
||||||
"UPDATE changelog SET user_id = '{nid}' WHERE user_id = '{oid}'",
|
"UPDATE useritem SET user_id = '{nid}' WHERE user_id = '{oid}'",
|
||||||
]
|
"UPDATE changelog SET user_id = '{nid}' WHERE user_id = '{oid}'",
|
||||||
for sql in statements:
|
]
|
||||||
run_sql(sql.format(oid=settings.OLD_USER_ID, nid=settings.USER_ID))
|
for sql in statements:
|
||||||
|
run_sql(sql.format(oid=settings.OLD_USER_ID, nid=settings.USER_ID))
|
||||||
if old <= '20151201-384-03c2439':
|
if old <= '20151201-384-03c2439':
|
||||||
with db.session():
|
with db.session():
|
||||||
import item.models
|
import item.models
|
||||||
|
|
Loading…
Reference in a new issue