Skip to content

Commit 26266f6

Browse files
author
Rafael Grigorian
committed
Fixed #99
1 parent 406bd93 commit 26266f6

File tree

2 files changed

+6
-57
lines changed

2 files changed

+6
-57
lines changed

docker-compose.yml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ services:
2626
- "9000"
2727
links:
2828
- mysql
29-
- redis
3029
php-cli:
3130
image: jetrails/magento-alpine:php-cli-5.6
3231
volumes:
@@ -37,7 +36,6 @@ services:
3736
- php-cli.docker.internal
3837
links:
3938
- mysql
40-
- redis
4139
php-cron:
4240
image: jetrails/magento-alpine:php-cron-5.6
4341
restart: unless-stopped
@@ -51,7 +49,6 @@ services:
5149
- VERBOSE=false
5250
links:
5351
- mysql
54-
- redis
5552
nginx:
5653
image: jetrails/magento-alpine:nginx
5754
restart: unless-stopped
@@ -97,12 +94,3 @@ services:
9794
- nginx
9895
ports:
9996
- "80:80"
100-
redis:
101-
image: jetrails/magento-alpine:redis
102-
restart: unless-stopped
103-
networks:
104-
default:
105-
aliases:
106-
- redis.docker.internal
107-
environment:
108-
- VERBOSE=false

src/app/code/community/JetRails/Cloudflare/Model/Adminhtml/Api/Overview/Configuration.php

Lines changed: 6 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -12,43 +12,6 @@
1212
class JetRails_Cloudflare_Model_Adminhtml_Api_Overview_Configuration
1313
extends Mage_Core_Model_Abstract {
1414

15-
/**
16-
* This method caches a zone value based on a passed domain. This is
17-
* used cache the result of an API call within an entire session. The
18-
* zone id is cached, because it gets used a lot throughout a typical
19-
* session.
20-
* @param string domain Domain to cache as key
21-
* @param string zone The zone to cache as value
22-
* @return void
23-
*/
24-
protected function _setCached ( $domain, $zone ) {
25-
$session = Mage::getSingleton ("core/session");
26-
$lookup = array ();
27-
if ( !empty ( $session->getDomainZone () ) ) {
28-
$lookup = $session->getDomainZone ();
29-
}
30-
$lookup [ "$domain" ] = "$zone";
31-
$session->setDomainZone ( $lookup );
32-
}
33-
34-
/**
35-
* This method attempts to retrieve a zone id from cache, based on a
36-
* domain name. If there is no zone id for the passed domain name, then
37-
* false is returned.
38-
* @param string domain Domain for zone id
39-
* @return mixed Cached zone id or false
40-
*/
41-
protected function _getCached ( $domain ) {
42-
$session = Mage::getSingleton ("core/session");
43-
$lookup = $session->getDomainZone ();
44-
if ( !empty ( $lookup )
45-
&& is_array ( $lookup )
46-
&& array_key_exists ( "$domain", $lookup ) ) {
47-
return $lookup ["$domain"];
48-
}
49-
return false;
50-
}
51-
5215
/**
5316
* This method takes in a zone and a token. It then makes an API call to
5417
* Cloudflare and finds out if the supplied token for the zone is valid.
@@ -60,6 +23,11 @@ public function validateAuth ( $zone = null, $token = null ) {
6023
$api = Mage::getModel ("cloudflare/api_request");
6124
$api->setType ( $api::REQUEST_GET );
6225
$response = $api->resolve ("user/tokens/verify");
26+
if ( !$response->success ) {
27+
return false;
28+
}
29+
if ( !$zone ) $zone = $this->getZoneId ();
30+
$response = $api->resolve ("zones/$zone");
6331
return $response->success;
6432
}
6533

@@ -71,14 +39,7 @@ public function validateAuth ( $zone = null, $token = null ) {
7139
*/
7240
public function getZoneId () {
7341
$data = Mage::helper ("cloudflare/data");
74-
$domain = $data->getDomainName ();
75-
$cached = $this->_getCached ("$domain");
76-
if ( $cached !== false ) {
77-
return $cached;
78-
}
79-
$zone = $data->getAuthZone ();
80-
$this->_setCached ( "$domain", $zone );
81-
return $zone;
42+
return $data->getAuthZone ();
8243
}
8344

8445
}

0 commit comments

Comments
 (0)