data[ $key ] = $value; } /** * @param Request $request */ public function set_from_request( Request $request ) { $redirect_to = $request->request( self::WP_LOGIN_REDIRECT_TO ); $remember_me = $request->post( self::WP_LOGIN_REMEMBER_ME ); if ( is_null( $remember_me ) ) { $remember_me = $request->get( self::WP_LOGIN_REMEMBER_ME ); } $test_cookie = $request->post( self::WP_LOGIN_TEST_COOKIE ); $interim_login = $request->request( self::WP_LOGIN_INTERIM_LOGIN ); $customize_login = $request->request( self::WP_LOGIN_CUSTOMIZE_LOGIN ); $remember_device = $request->post( self::TWOFAS_LOGIN_REMEMBER_DEVICE ); if ( ! is_null( $redirect_to ) ) { $this->set( 'redirect_to', $redirect_to ); } if ( ! is_null( $remember_me ) ) { $this->set( 'remember_me', $remember_me ); } if ( ! is_null( $test_cookie ) ) { $this->set( 'test_cookie', $test_cookie ); } if ( ! is_null( $interim_login ) ) { $this->set( 'interim_login', $interim_login ); } if ( ! is_null( $customize_login ) ) { $this->set( 'customize_login', $customize_login ); } if ( ! is_null( $remember_device ) ) { $this->set( 'remember_device', $remember_device ); } if ( $this->is_open_new_auth_request( $request ) ) { $this->set( 'open_new_auth_action', true ); } } /** * @param IntegrationUser $integration_user */ public function set_from_integration_user( IntegrationUser $integration_user ) { $phone_number = $integration_user->getPhoneNumber()->phoneNumber(); $this->set( 'offline_codes_count', $integration_user->getBackupCodesCount() ); $this->set( 'has_mobile_user', $integration_user->hasMobileUser() ); if ( ! is_null( $phone_number ) ) { $this->set( 'phone_number_ending', substr( $phone_number, - 3 ) ); } } /** * @param User_Storage $user_data * * @throws User_Not_Found_Exception */ public function set_from_storage( User_Storage $user_data ) { $this->set( 'is_sms_enabled', $user_data->is_sms_enabled() ); $this->set( 'are_offline_codes_enabled', $user_data->are_offline_codes_enabled() ); $this->set( 'is_totp_enabled', $user_data->is_totp_enabled() ); } /** * @param string $key * * @return mixed */ public function get( $key ) { if ( ! array_key_exists( $key, $this->data ) ) { return null; } return $this->data[ $key ]; } /** * @return array */ public function get_all() { return $this->data; } /** * @param Request $request * * @return bool */ private function is_open_new_auth_request( Request $request ) { return $request->is_login_action_equal_to( Login_Action::OPEN_NEW_SMS_AUTHENTICATION ) || $request->is_login_action_equal_to( Login_Action::OPEN_NEW_CALL_AUTHENTICATION ); } }