Kallithea issues archive

Issue #38: After using rebranddb.py, user admin can no longer log in

Reported by: Ba Manzi
State: resolved
Created on: 2014-09-12 06:46
Updated on: 2014-09-24 17:53

Description

Background: I used rebranddb.py to upgrade rhodecode-2.2.5 to kallithea-0.1.

But after this, user admin can no longer log in.

Debugging result indicates user admin's extern_type renamed to kallithea, but I think it should be internal.

Attachments

Comments

Comment by Mads Kiilerich, on 2014-09-12 10:35

Hmm. Right. I wonder why I and others haven't noticed that.

Can you confirm the following works?

--- a/kallithea/bin/rebranddb.py
+++ b/kallithea/bin/rebranddb.py
@@ -70,6 +70,9 @@ def do_migrate(db, old, new):
         except KeyError, e:
             print 'Not renaming settings:', e

+    old_auth_name = 'internal' if old == 'kallithea' else old
+    new_auth_name = 'internal' if new == 'kallithea' else new
+
     # using this API because ... dunno ... it is simple and works
     conn = metadata.bind.connect()
     trans = conn.begin()
@@ -81,7 +84,7 @@ def do_migrate(db, old, new):
     except AttributeError:
         print 'No extern_name to rename'
     else:
-        t.update().where(t.c.extern_name == old).values(extern_name=new).execute()
+        t.update().where(t.c.extern_name == old_auth_name).values(extern_name=new_auth_name).execute()

     print 'Bulk fixing of User extern_type'
     try:
@@ -89,7 +92,7 @@ def do_migrate(db, old, new):
     except AttributeError:
         print 'No extern_type to rename'
     else:
-        t.update().where(t.c.extern_type == old).values(extern_type=new).execute()
+        t.update().where(t.c.extern_type == old_auth_name).values(extern_type=new_auth_name).execute()

     trans.commit()

@@ -132,8 +135,6 @@ def do_migrate(db, old, new):
     session.commit()

     print 'Fixing auth module names'
-    old_auth_name = 'internal' if old == 'kallithea' else old
-    new_auth_name = 'internal' if new == 'kallithea' else new
     for s in session.query(Setting).filter(Setting.app_settings_name == 'auth_plugins').all():
         print '- fixing %s' % s.app_settings_name
         s.app_settings_value = (s.app_settings_value

Comment by Ba Manzi, on 2014-09-15 05:56

Yes, it works. I tested against the database backup (I've modified the production database manually to make it work) and 'extern_type' correctly migrated to 'internal'.

Comment by Mads Kiilerich, on 2014-09-19 07:26

Issue #40 was marked as a duplicate of this issue.

Comment by Mads Kiilerich, on 2014-09-24 17:53

Fix pushed.