Commit 6ee12fa0 authored by Erick Hitter's avatar Erick Hitter
Browse files

Track environment so keys can be stored separately.

parent 736360fc
...@@ -36,6 +36,7 @@ class Authy_WP { ...@@ -36,6 +36,7 @@ class Authy_WP {
protected $api = null; protected $api = null;
protected $api_key = null; protected $api_key = null;
protected $api_endpoint = null; protected $api_endpoint = null;
protected $environment = 'production';
// Commong plugin elements // Commong plugin elements
protected $settings_page = 'authy-for-wp'; protected $settings_page = 'authy-for-wp';
...@@ -134,13 +135,13 @@ class Authy_WP { ...@@ -134,13 +135,13 @@ class Authy_WP {
'development' => 'http://sandbox-api.authy.com' 'development' => 'http://sandbox-api.authy.com'
); );
$environment = $this->get_setting( 'environment' ); $this->environment = $this->get_setting( 'environment' );
$api_key = $this->get_setting( 'api_key_' . $environment ); $api_key = $this->get_setting( 'api_key_' . $this->environment );
if ( $api_key && isset( $endpoints[ $environment ] ) ) { if ( $api_key && isset( $endpoints[ $this->environment ] ) ) {
$this->api_key = $api_key; $this->api_key = $api_key;
$this->api_endpoint = $endpoints[ $environment ]; $this->api_endpoint = $endpoints[ $this->environment ];
} }
$this->api = Authy_WP_API::instance( $this->api_key, $this->api_endpoint ); $this->api = Authy_WP_API::instance( $this->api_key, $this->api_endpoint );
...@@ -176,7 +177,7 @@ class Authy_WP { ...@@ -176,7 +177,7 @@ class Authy_WP {
$this->settings = wp_parse_args( $this->settings, array( $this->settings = wp_parse_args( $this->settings, array(
'api_key_production' => '', 'api_key_production' => '',
'api_key_development' => '', 'api_key_development' => '',
'environment' => 'development' 'environment' => apply_filters( 'authy_wp_environment', 'production' )
) ); ) );
} }
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment