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.")
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.")
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)
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)
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)
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)
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/")
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))
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)
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.")