request = $request; $this->trusted_devices_storage = $trusted_devices_storage; } /** * @param WP_Error|WP_User $user * @param JSON_Response|View_Response|null $response * * @return JSON_Response|View_Response|Redirect_Response|null */ public function handle( $user, $response = null ) { $remember_device = $this->request->post( Authenticate_Filter::TWOFAS_REMEMBER_DEVICE_KEY ); if ( ! $this->is_wp_user( $user ) && $response instanceof JSON_Response && 200 === $response->get_status_code() && ! empty( $remember_device ) && $this->request->is_login_action_equal_to( Login_Action::VERIFY_TOTP_CODE ) ) { $body = $response->get_body(); $user_id = $body['user_id']; $this->trusted_devices_storage->add_trusted_device( $user_id ); } return $this->run_next( $user, $response ); } }