From e060c397904293c8f47bc37efcf194b30bf53228 Mon Sep 17 00:00:00 2001 From: yazhog Date: Sun, 7 Sep 2025 00:16:29 +0300 Subject: [PATCH] Fix state detection for registration in auth middleware --- app/middlewares/auth.py | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/app/middlewares/auth.py b/app/middlewares/auth.py index cb0d5ad3..c89836bc 100644 --- a/app/middlewares/auth.py +++ b/app/middlewares/auth.py @@ -44,16 +44,13 @@ class AuthMiddleware(BaseMiddleware): current_state = await state.get_state() registration_states = [ - RegistrationStates.waiting_for_rules_accept, - RegistrationStates.waiting_for_referral_code + RegistrationStates.waiting_for_rules_accept.state, + RegistrationStates.waiting_for_referral_code.state ] - + is_registration_process = ( (isinstance(event, Message) and event.text and event.text.startswith('/start')) - or ( - current_state - and any(str(state) in str(current_state) for state in registration_states) - ) + or (current_state in registration_states) or ( isinstance(event, CallbackQuery) and event.data @@ -98,16 +95,18 @@ class AuthMiddleware(BaseMiddleware): current_state = await state.get_state() registration_states = [ - RegistrationStates.waiting_for_rules_accept, - RegistrationStates.waiting_for_referral_code + RegistrationStates.waiting_for_rules_accept.state, + RegistrationStates.waiting_for_referral_code.state ] - + is_start_or_registration = ( (isinstance(event, Message) and event.text and event.text.startswith('/start')) - or (isinstance(event, CallbackQuery) and current_state and - any(str(state) in str(current_state) for state in registration_states)) - or (isinstance(event, CallbackQuery) and event.data and - (event.data in ['rules_accept', 'rules_decline', 'referral_skip'])) + or (current_state in registration_states) + or ( + isinstance(event, CallbackQuery) + and event.data + and (event.data in ['rules_accept', 'rules_decline', 'referral_skip']) + ) ) if is_start_or_registration: