Skip to content

Commit 9140248

Browse files
committed
Patrol 1.4.2
- Adds login (`/{cpTrigger}/login`) redirect when using `limitCpAccessTo` ( Issue #19 ) - Fixes issue #21 where `authorizedIps` was not handled correctly in some cases
1 parent 7105134 commit 9140248

File tree

3 files changed

+20
-7
lines changed

3 files changed

+20
-7
lines changed

PatrolPlugin.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Patrol simplifies maintenance and SSL for sites built with Craft
88
*
99
* @author Selvin Ortiz <selvin@selvin.co>
10-
* @version 1.4.1
10+
* @version 1.4.2
1111
* @package Craft
1212
* @category Security
1313
* @since Craft 1.3
@@ -68,7 +68,7 @@ public function getName($real = false)
6868
*/
6969
public function getVersion()
7070
{
71-
return '1.4.1';
71+
return '1.4.2';
7272
}
7373

7474
/**

releases.json

+9
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
11
[
2+
{
3+
"version": "1.4.2",
4+
"downloadUrl": "https://github.com/selvinortiz/craft.patrol/archive/v1.4.2.zip",
5+
"date": "2017-01-11T13:13:00-06:00",
6+
"notes": [
7+
"[Added] Added login (`/{cpTrigger}/login`) redirect when using `limitCpAccessTo`",
8+
"[Fixed] Fixed issue where `authorizedIps` was not properly handled in some cases"
9+
]
10+
},
211
{
312
"version": "1.4.1",
413
"downloadUrl": "https://github.com/selvinortiz/craft.patrol/archive/v1.4.1.zip",

services/PatrolService.php

+9-5
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,14 @@ protected function enforceMaintenanceRules()
145145

146146
if ($isCpRequest && is_array($limitCpAccessTo) && count($limitCpAccessTo) && ! $isCpLoginPage)
147147
{
148-
if (craft()->userSession->isLoggedIn())
148+
// Redirect to login page
149+
if (! craft()->userSession->isLoggedIn())
149150
{
151+
craft()->request->redirect(sprintf('/%s/login', craft()->config->get('cpTrigger')));
152+
}
153+
else
154+
{
155+
// Verify
150156
$user = craft()->userSession->getUser();
151157

152158
if (in_array($user->email, $limitCpAccessTo) || in_array($user->username, $limitCpAccessTo))
@@ -250,11 +256,9 @@ protected function getDynamicParams()
250256
*/
251257
public function parseAuthorizedIps($ips)
252258
{
253-
$ips = trim($ips);
254-
255-
if (is_string($ips) && ! empty($ips))
259+
if (is_string($ips))
256260
{
257-
$ips = explode(PHP_EOL, $ips);
261+
$ips = explode(PHP_EOL, trim($ips));
258262
}
259263

260264
return $this->filterOutArrayValues(

0 commit comments

Comments
 (0)