Browse Source

Add token

dev
philipp lang 2 years ago
parent
commit
32c3e111cc
  1. 4
      assets/js/Stepper.vue
  2. 2
      settings.php
  3. 13
      src/Stepper.php
  4. 14
      templates/access-key-input.htm

4
assets/js/Stepper.vue

@ -134,12 +134,14 @@
v-model="innerStep"
class="mt-6"
:nextable="
value.object_address.length > 0 &&
value.object_zip.length > 0 &&
value.object_location.length > 0 &&
value.firstname.length !== 0 &&
value.lastname.length !== 0 &&
value.email.length !== 0 &&
value.phone.length !== 0
value.phone.length !== 0 &&
value.datenschutz === true
"
submit
></pagination>

2
settings.php

@ -16,7 +16,7 @@ add_action('admin_init', function () {
it_render_template('color-input.htm', ['value' => $options[$args['key']], 'name' => $args['key']]);
}, 'it-slider', 'it-slider-section', ['key' => 'it-slider-color']);
add_settings_field('it-slider-access-key-field', 'Accountstatus', function ($args) {
add_settings_field('it-slider-access-key-field', 'Access Key', function ($args) {
$options = get_option('it-slider-options');
it_render_template('access-key-input.htm', ['value' => $options[$args['key']], 'name' => $args['key']]);
}, 'it-slider', 'it-slider-section', ['key' => 'it-slider-access-key']);

13
src/Stepper.php

@ -10,11 +10,13 @@ class Stepper
public string $url;
public string $scriptUrl;
public string $baseUrl;
public function loadEnv(string $dir): void
{
$env = Dotenv::createImmutable($dir);
$env->safeLoad();
$env = $env->safeLoad();
$this->baseUrl = $env['STEPPER_URL'] ?? 'https://app.immotooler.com';
}
public function initFrontend()
@ -54,13 +56,18 @@ class Stepper
$client = new Client();
$payload = json_decode(file_get_contents('php://input'), true);
$client->post(STEPPER_URL, [
$client->post($this->baseUrl . '/api/lead', [
'json' => $payload,
'headers' => [
'Accept' => 'application/json',
'Content-Type' => 'application/json',
'Authorization' => 'Bearer ' . STEPPER_TOKEN,
'Authorization' => 'Bearer ' . $this->token(),
]
]);
}
protected function token(): string
{
return get_option('it-slider-options')['it-slider-access-key'];
}
}

14
templates/access-key-input.htm

@ -1,13 +1 @@
<?php if ($value === null): ?>
<p>
Sie sind nicht mit Immotooler verbunden
</p>
<p>
<a href="https://app.immotooler.com/oauth/authorize" class="it-login-button">
<img src="<?php echo $pluginDir; ?>resources/img/immotooler.png">
<span>Mit Immotooler verbinden</span>
</a>
</p>
<?php else: ?>
<input type="color" value="<?php echo esc_attr($value); ?>" name="it-slider-options[<?php echo esc_attr($name); ?>]">
<?php endif; ?>
<input type="text" value="<?php echo esc_attr($value); ?>" name="it-slider-options[<?php echo esc_attr($name); ?>]">

Loading…
Cancel
Save