diff --git a/apps/assets/migrations/0069_change_node_key0_to_key1.py b/apps/assets/migrations/0069_change_node_key0_to_key1.py deleted file mode 100644 index 4024386dc42255a60be6d51b4cfac459f6254fd5..0000000000000000000000000000000000000000 --- a/apps/assets/migrations/0069_change_node_key0_to_key1.py +++ /dev/null @@ -1,59 +0,0 @@ -from django.db import migrations -from django.db.transaction import atomic - -default_id = '00000000-0000-0000-0000-000000000002' - - -def change_key0_to_key1(apps, schema_editor): - from orgs.utils import set_current_org - - # https://stackoverflow.com/questions/28777338/django-migrations-runpython-not-able-to-call-model-methods - Organization = apps.get_model('orgs', 'Organization') - Node = apps.get_model('assets', 'Node') - - print() - org = Organization.objects.get(id=default_id) - set_current_org(org) - - exists_0 = Node.objects.filter(key__startswith='0').exists() - if not exists_0: - print(f'--> Not exist key=0 nodes, do nothing.') - return - - key_1_count = Node.objects.filter(key__startswith='1').count() - if key_1_count > 1: - print(f'--> Node key=1 have children, can`t just delete it. Please contact JumpServer team') - return - - root_node = Node.objects.filter(key='1').first() - if root_node and root_node.assets.exists(): - print(f'--> Node key=1 has assets, do nothing.') - return - - with atomic(): - if root_node: - print(f'--> Delete node key=1') - root_node.delete() - - nodes_0 = Node.objects.filter(key__startswith='0') - - for n in nodes_0: - old_key = n.key - key_list = n.key.split(':') - key_list[0] = '1' - new_key = ':'.join(key_list) - n.key = new_key - n.save() - print('--> Modify key ( {} > {} )'.format(old_key, new_key)) - - -class Migration(migrations.Migration): - - dependencies = [ - ('orgs', '0010_auto_20210219_1241'), - ('assets', '0068_auto_20210312_1455'), - ] - - operations = [ - migrations.RunPython(change_key0_to_key1) - ] diff --git a/apps/authentication/views/login.py b/apps/authentication/views/login.py index 9f628e6e89ae67c39adf1fb4cfe9442f33134757..e1a3ab4b6db7be84a4a5913a4fd06575ad91e9c9 100644 --- a/apps/authentication/views/login.py +++ b/apps/authentication/views/login.py @@ -69,6 +69,7 @@ class UserLoginView(mixins.AuthMixin, FormView): new_form = form_cls(data=form.data) new_form._errors = form.errors context = self.get_context_data(form=new_form) + self.request.session.set_test_cookie() return self.render_to_response(context) except (errors.PasswdTooSimple, errors.PasswordRequireResetError) as e: return redirect(e.url)