Exemplo n.º 1
0
    def handle(self, *args, **options):
        # type: (*Any, **Any) -> None
        realm = self.get_realm(options)
        user_profile = self.get_user(options['email'], realm)

        print("Deactivating %s (%s) - %s" % (user_profile.full_name,
                                             user_profile.email,
                                             user_profile.realm.string_id))
        print("%s has the following active sessions:" % (user_profile.email,))
        for session in user_sessions(user_profile):
            print(session.expire_date, session.get_decoded())
        print("")
        print("%s has %s active bots that will also be deactivated." % (
            user_profile.email,
            UserProfile.objects.filter(
                is_bot=True, is_active=True, bot_owner=user_profile
            ).count()
        ))

        if not options["for_real"]:
            print("This was a dry run. Pass -f to actually deactivate.")
            exit(1)

        do_deactivate_user(user_profile)
        print("Sessions deleted, user deactivated.")
Exemplo n.º 2
0
    def handle(self, *args: Any, **options: Any) -> None:
        realm = self.get_realm(options)
        user_profile = self.get_user(options["email"], realm)

        print(
            f"Deactivating {user_profile.full_name} ({user_profile.delivery_email}) - {user_profile.realm.string_id}"
        )
        print(
            f"{user_profile.delivery_email} has the following active sessions:"
        )
        for session in user_sessions(user_profile):
            print(session.expire_date, session.get_decoded())
        print("")
        print("{} has {} active bots that will also be deactivated.".format(
            user_profile.delivery_email,
            UserProfile.objects.filter(
                is_bot=True,
                is_active=True,
                bot_owner=user_profile,
            ).count(),
        ))

        if not options["for_real"]:
            raise CommandError(
                "This was a dry run. Pass -f to actually deactivate.")

        do_deactivate_user(user_profile)
        print("Sessions deleted, user deactivated.")
Exemplo n.º 3
0
 def test_delete_session(self) -> None:
     user_profile = self.example_user('hamlet')
     self.login_user(user_profile)
     self.assertIn('_auth_user_id', self.client.session)
     for session in user_sessions(user_profile):
         delete_session(session)
     result = self.client_get("/")
     self.assertEqual('/login/', result.url)
Exemplo n.º 4
0
 def test_delete_session(self) -> None:
     user_profile = self.example_user('hamlet')
     self.login_user(user_profile)
     self.assertIn('_auth_user_id', self.client.session)
     for session in user_sessions(user_profile):
         delete_session(session)
     result = self.client_get("/")
     self.check_rendered_web_public_visitor(result)
Exemplo n.º 5
0
 def test_delete_session(self) -> None:
     user_profile = self.example_user("hamlet")
     self.login_user(user_profile)
     self.assertIn("_auth_user_id", self.client.session)
     for session in user_sessions(user_profile):
         delete_session(session)
     result = self.client_get("/")
     self.check_rendered_spectator(result)
Exemplo n.º 6
0
 def test_delete_session(self) -> None:
     user_profile = self.example_user('hamlet')
     email = user_profile.email
     self.login(email)
     self.assertIn('_auth_user_id', self.client.session)
     for session in user_sessions(user_profile):
         delete_session(session)
     result = self.client_get("/")
     self.assertEqual('/login', result.url)
Exemplo n.º 7
0
 def test_delete_session(self) -> None:
     user_profile = self.example_user("hamlet")
     self.login_user(user_profile)
     self.assertIn("_auth_user_id", self.client.session)
     for session in user_sessions(user_profile):
         delete_session(session)
     result = self.client_get("/")
     self.assertEqual(result.status_code, 302)
     self.assertEqual(result.url, "/login/")
Exemplo n.º 8
0
 def test_delete_session(self) -> None:
     user_profile = self.example_user("hamlet")
     self.login_user(user_profile)
     self.assertIn("_auth_user_id", self.client.session)
     for session in user_sessions(user_profile):
         delete_session(session)
     result = self.client_get("/")
     self.assertEqual(result.status_code, 200)
     self.assertTrue('is_spectator":true' in str(result.content))
Exemplo n.º 9
0
 def test_delete_session(self):
     # type: () -> None
     user_profile = self.example_user('hamlet')
     email = user_profile.email
     self.login(email)
     self.assertIn('_auth_user_id', self.client.session)
     for session in user_sessions(user_profile):
         delete_session(session)
     result = self.client_get("/")
     self.assertEqual('/login', result.url)
Exemplo n.º 10
0
    def handle(self, *args, **options):
        # type: (*Any, **Any) -> None
        user_profile = get_user_profile_by_email(options['email'])

        print("Deactivating %s (%s) - %s" %
              (user_profile.full_name, user_profile.email,
               user_profile.realm.string_id))
        print("%s has the following active sessions:" % (user_profile.email, ))
        for session in user_sessions(user_profile):
            print(session.expire_date, session.get_decoded())
        print("")
        print(
            "%s has %s active bots that will also be deactivated." %
            (user_profile.email,
             UserProfile.objects.filter(
                 is_bot=True, is_active=True, bot_owner=user_profile).count()))

        if not options["for_real"]:
            print("This was a dry run. Pass -f to actually deactivate.")
            exit(1)

        do_deactivate_user(user_profile)
        print("Sessions deleted, user deactivated.")