| @@ -3,69 +3,69 @@ | ||
| 3 | 3 | class AdminLoginForm extends MemberLoginForm | 
| 4 | 4 |  { | 
| 5 | 5 | |
| 6 | - public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) | |
| 7 | -    { | |
| 8 | - parent::__construct($controller, $name, $fields, $actions, $checkCurrentUser); | |
| 6 | + public function __construct($controller, $name, $fields = null, $actions = null, $checkCurrentUser = true) | |
| 7 | +	{ | |
| 8 | + parent::__construct($controller, $name, $fields, $actions, $checkCurrentUser); | |
| 9 | 9 | |
| 10 | -        if ($field = $this->Actions()->fieldByName('forgotPassword')) { | |
| 11 | - // replaceField won't work, since it's a dataless field | |
| 12 | -            $this->Actions()->removeByName('forgotPassword'); | |
| 13 | - $this->Actions()->push(new LiteralField( | |
| 14 | - 'forgotPassword', | |
| 15 | - '<p id="ForgotPassword"><a href="AdminSecurity/lostpassword">' | |
| 16 | -                . _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>' | |
| 17 | - )); | |
| 18 | - } | |
| 10 | +		if ($field = $this->Actions()->fieldByName('forgotPassword')) { | |
| 11 | + // replaceField won't work, since it's a dataless field | |
| 12 | +			$this->Actions()->removeByName('forgotPassword'); | |
| 13 | + $this->Actions()->push(new LiteralField( | |
| 14 | + 'forgotPassword', | |
| 15 | + '<p id="ForgotPassword"><a href="AdminSecurity/lostpassword">' | |
| 16 | +				. _t('Member.BUTTONLOSTPASSWORD', "I've lost my password") . '</a></p>' | |
| 17 | + )); | |
| 18 | + } | |
| 19 | 19 | |
| 20 | - Requirements::customScript(<<<JS | |
| 20 | + Requirements::customScript(<<<JS | |
| 21 | 21 |  			(function() { | 
| 22 | 22 |  				var el = document.getElementById("AdminLoginForm_LoginForm_Email"); | 
| 23 | 23 | if(el && el.focus) el.focus(); | 
| 24 | 24 | })(); | 
| 25 | 25 | JS | 
| 26 | - ); | |
| 27 | - } | |
| 26 | + ); | |
| 27 | + } | |
| 28 | 28 | |
| 29 | - /** | |
| 30 | - * | |
| 31 | - */ | |
| 32 | - public function forgotPassword($data) | |
| 33 | -    { | |
| 34 | - $SQL_data = Convert::raw2sql($data); | |
| 35 | - $SQL_email = $SQL_data['Email']; | |
| 29 | + /** | |
| 30 | + * | |
| 31 | + */ | |
| 32 | + public function forgotPassword($data) | |
| 33 | +	{ | |
| 34 | + $SQL_data = Convert::raw2sql($data); | |
| 35 | + $SQL_email = $SQL_data['Email']; | |
| 36 | 36 | |
| 37 | - /* @var $member Member */ | |
| 38 | -        $member = DataObject::get_one('Member', "\"Email\" = '{$SQL_email}'"); | |
| 37 | + /* @var $member Member */ | |
| 38 | +		$member = DataObject::get_one('Member', "\"Email\" = '{$SQL_email}'"); | |
| 39 | 39 | |
| 40 | - $backUrlString = ''; | |
| 41 | -        if (isset($data['BackURL']) && $backURL = $data['BackURL']) { | |
| 42 | - $backUrlString = '?BackURL=' . $backURL; | |
| 43 | - } | |
| 40 | + $backUrlString = ''; | |
| 41 | +		if (isset($data['BackURL']) && $backURL = $data['BackURL']) { | |
| 42 | + $backUrlString = '?BackURL=' . $backURL; | |
| 43 | + } | |
| 44 | 44 | |
| 45 | -        if ($member) { | |
| 46 | - $token = $member->generateAutologinTokenAndStoreHash(); | |
| 45 | +		if ($member) { | |
| 46 | + $token = $member->generateAutologinTokenAndStoreHash(); | |
| 47 | 47 | |
| 48 | - /* @var $e Member_ForgotPasswordEmail */ | |
| 49 | - $e = Member_ForgotPasswordEmail::create(); | |
| 50 | - $e->populateTemplate($member); | |
| 51 | - $e->populateTemplate(array( | |
| 52 | - 'PasswordResetLink' => AdminSecurity::getPasswordResetLink($member, $token) | |
| 53 | - )); | |
| 54 | - $e->setTo($member->Email); | |
| 55 | - $e->send(); | |
| 48 | + /* @var $e Member_ForgotPasswordEmail */ | |
| 49 | + $e = Member_ForgotPasswordEmail::create(); | |
| 50 | + $e->populateTemplate($member); | |
| 51 | + $e->populateTemplate(array( | |
| 52 | + 'PasswordResetLink' => AdminSecurity::getPasswordResetLink($member, $token) | |
| 53 | + )); | |
| 54 | + $e->setTo($member->Email); | |
| 55 | + $e->send(); | |
| 56 | 56 | |
| 57 | -            $this->controller->redirect('AdminSecurity/passwordsent/' . urlencode($data['Email'])); | |
| 58 | -        } elseif ($data['Email']) { | |
| 59 | - // Avoid information disclosure by displaying the same status, | |
| 60 | - // regardless wether the email address actually exists | |
| 61 | -            $this->controller->redirect('AdminSecurity/passwordsent/' . urlencode($data['Email'])); | |
| 62 | -        } else { | |
| 63 | - $this->sessionMessage( | |
| 64 | -                _t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.'), | |
| 65 | - 'bad' | |
| 66 | - ); | |
| 57 | +			$this->controller->redirect('AdminSecurity/passwordsent/' . urlencode($data['Email'])); | |
| 58 | +		} elseif ($data['Email']) { | |
| 59 | + // Avoid information disclosure by displaying the same status, | |
| 60 | + // regardless wether the email address actually exists | |
| 61 | +			$this->controller->redirect('AdminSecurity/passwordsent/' . urlencode($data['Email'])); | |
| 62 | +		} else { | |
| 63 | + $this->sessionMessage( | |
| 64 | +				_t('Member.ENTEREMAIL', 'Please enter an email address to get a password reset link.'), | |
| 65 | + 'bad' | |
| 66 | + ); | |
| 67 | 67 | |
| 68 | -            $this->controller->redirect('AdminSecurity/lostpassword'); | |
| 69 | - } | |
| 70 | - } | |
| 68 | +			$this->controller->redirect('AdminSecurity/lostpassword'); | |
| 69 | + } | |
| 70 | + } | |
| 71 | 71 | } | 
| @@ -13,123 +13,123 @@ | ||
| 13 | 13 | */ | 
| 14 | 14 | class IpAccess | 
| 15 | 15 |  { | 
| 16 | - /** | |
| 17 | - * @var array | |
| 18 | - */ | |
| 19 | - public $allowedIps = array(); | |
| 16 | + /** | |
| 17 | + * @var array | |
| 18 | + */ | |
| 19 | + public $allowedIps = array(); | |
| 20 | 20 | |
| 21 | - /** | |
| 22 | - * @var string | |
| 23 | - */ | |
| 24 | - private $ip = ''; | |
| 21 | + /** | |
| 22 | + * @var string | |
| 23 | + */ | |
| 24 | + private $ip = ''; | |
| 25 | 25 | |
| 26 | - /** | |
| 27 | - * IpAccess constructor. | |
| 28 | - * | |
| 29 | - * @param string $ip | |
| 30 | - * @param array $allowedIps | |
| 31 | - */ | |
| 32 | - public function __construct($ip = '', $allowedIps = array()) | |
| 33 | -    { | |
| 34 | - $this->ip = $ip; | |
| 35 | - $this->allowedIps = $allowedIps; | |
| 36 | - } | |
| 26 | + /** | |
| 27 | + * IpAccess constructor. | |
| 28 | + * | |
| 29 | + * @param string $ip | |
| 30 | + * @param array $allowedIps | |
| 31 | + */ | |
| 32 | + public function __construct($ip = '', $allowedIps = array()) | |
| 33 | +	{ | |
| 34 | + $this->ip = $ip; | |
| 35 | + $this->allowedIps = $allowedIps; | |
| 36 | + } | |
| 37 | 37 | |
| 38 | - /** | |
| 39 | - * @param $ip | |
| 40 | - */ | |
| 41 | - public function setIp($ip) | |
| 42 | -    { | |
| 43 | - $this->ip = $ip; | |
| 44 | - } | |
| 38 | + /** | |
| 39 | + * @param $ip | |
| 40 | + */ | |
| 41 | + public function setIp($ip) | |
| 42 | +	{ | |
| 43 | + $this->ip = $ip; | |
| 44 | + } | |
| 45 | 45 | |
| 46 | - /** | |
| 47 | - * @return string | |
| 48 | - */ | |
| 49 | - public function hasAccess() | |
| 50 | -    { | |
| 51 | -        if (!$this->allowedIps) { | |
| 52 | - return 'allowed'; | |
| 53 | -        } elseif ($match = $this->matchExact()) { | |
| 54 | - return $match; | |
| 55 | -        } elseif ($match = $this->matchRange()) { | |
| 56 | - return $match; | |
| 57 | -        } elseif ($match = $this->matchCIDR()) { | |
| 58 | - return $match; | |
| 59 | -        } elseif ($match = $this->matchWildCard()) { | |
| 60 | - return $match; | |
| 61 | - } | |
| 62 | - } | |
| 46 | + /** | |
| 47 | + * @return string | |
| 48 | + */ | |
| 49 | + public function hasAccess() | |
| 50 | +	{ | |
| 51 | +		if (!$this->allowedIps) { | |
| 52 | + return 'allowed'; | |
| 53 | +		} elseif ($match = $this->matchExact()) { | |
| 54 | + return $match; | |
| 55 | +		} elseif ($match = $this->matchRange()) { | |
| 56 | + return $match; | |
| 57 | +		} elseif ($match = $this->matchCIDR()) { | |
| 58 | + return $match; | |
| 59 | +		} elseif ($match = $this->matchWildCard()) { | |
| 60 | + return $match; | |
| 61 | + } | |
| 62 | + } | |
| 63 | 63 | |
| 64 | - /** | |
| 65 | - * @return string | |
| 66 | - */ | |
| 67 | - public function matchExact() | |
| 68 | -    { | |
| 69 | -        if (in_array($this->ip, $this->allowedIps)) { | |
| 70 | - return $this->ip; | |
| 71 | - } | |
| 72 | - } | |
| 64 | + /** | |
| 65 | + * @return string | |
| 66 | + */ | |
| 67 | + public function matchExact() | |
| 68 | +	{ | |
| 69 | +		if (in_array($this->ip, $this->allowedIps)) { | |
| 70 | + return $this->ip; | |
| 71 | + } | |
| 72 | + } | |
| 73 | 73 | |
| 74 | - /** | |
| 75 | - * try to match against a ip range | |
| 76 | - * Example : 192.168.1.50-100 | |
| 77 | - */ | |
| 78 | - public function matchRange() | |
| 79 | -    { | |
| 80 | -        if ($ranges = array_filter($this->allowedIps, function ($ip) { | |
| 81 | - return strstr($ip, '-'); | |
| 82 | - }) | |
| 83 | -        ) { | |
| 84 | -            foreach ($ranges as $range) { | |
| 85 | - $first = substr($range, 0, strrpos($range, '.') + 1); | |
| 86 | - $last = substr(strrchr($range, '.'), 1); | |
| 87 | -                list ($start, $end) = explode('-', $last); | |
| 88 | -                for ($i = $start; $i <= $end; $i++) { | |
| 89 | -                    if ($this->ip === $first . $i) { | |
| 90 | - return $range; | |
| 91 | - } | |
| 92 | - } | |
| 93 | - } | |
| 94 | - } | |
| 95 | - } | |
| 74 | + /** | |
| 75 | + * try to match against a ip range | |
| 76 | + * Example : 192.168.1.50-100 | |
| 77 | + */ | |
| 78 | + public function matchRange() | |
| 79 | +	{ | |
| 80 | +		if ($ranges = array_filter($this->allowedIps, function ($ip) { | |
| 81 | + return strstr($ip, '-'); | |
| 82 | + }) | |
| 83 | +		) { | |
| 84 | +			foreach ($ranges as $range) { | |
| 85 | + $first = substr($range, 0, strrpos($range, '.') + 1); | |
| 86 | + $last = substr(strrchr($range, '.'), 1); | |
| 87 | +				list ($start, $end) = explode('-', $last); | |
| 88 | +				for ($i = $start; $i <= $end; $i++) { | |
| 89 | +					if ($this->ip === $first . $i) { | |
| 90 | + return $range; | |
| 91 | + } | |
| 92 | + } | |
| 93 | + } | |
| 94 | + } | |
| 95 | + } | |
| 96 | 96 | |
| 97 | - /** | |
| 98 | - * try to match cidr range | |
| 99 | - * Example : 192.168.1.0/24 | |
| 100 | - */ | |
| 101 | - public function matchCIDR() | |
| 102 | -    { | |
| 103 | -        if ($ranges = array_filter($this->allowedIps, function ($ip) { | |
| 104 | - return strstr($ip, '/'); | |
| 105 | - }) | |
| 106 | -        ) { | |
| 107 | -            foreach ($ranges as $cidr) { | |
| 108 | -                list ($net, $mask) = explode('/', $cidr); | |
| 109 | -                if ((ip2long($this->ip) & ~((1 << (32 - $mask)) - 1)) == ip2long($net)) { | |
| 110 | - return $cidr; | |
| 111 | - } | |
| 112 | - } | |
| 113 | - } | |
| 114 | - } | |
| 97 | + /** | |
| 98 | + * try to match cidr range | |
| 99 | + * Example : 192.168.1.0/24 | |
| 100 | + */ | |
| 101 | + public function matchCIDR() | |
| 102 | +	{ | |
| 103 | +		if ($ranges = array_filter($this->allowedIps, function ($ip) { | |
| 104 | + return strstr($ip, '/'); | |
| 105 | + }) | |
| 106 | +		) { | |
| 107 | +			foreach ($ranges as $cidr) { | |
| 108 | +				list ($net, $mask) = explode('/', $cidr); | |
| 109 | +				if ((ip2long($this->ip) & ~((1 << (32 - $mask)) - 1)) == ip2long($net)) { | |
| 110 | + return $cidr; | |
| 111 | + } | |
| 112 | + } | |
| 113 | + } | |
| 114 | + } | |
| 115 | 115 | |
| 116 | - /** | |
| 117 | - * try to match against a range that ends with a wildcard * | |
| 118 | - * Example : 192.168.1.* | |
| 119 | - * Example : 192.168.* | |
| 120 | - */ | |
| 121 | - public function matchWildCard() | |
| 122 | -    { | |
| 123 | -        if ($ranges = array_filter($this->allowedIps, function ($ip) { | |
| 124 | - return substr($ip, -1) === '*'; | |
| 125 | - }) | |
| 126 | -        ) { | |
| 127 | -            foreach ($ranges as $range) { | |
| 128 | -                if (substr($this->ip, 0, strlen(substr($range, 0, -1))) === substr($range, 0, -1)) { | |
| 129 | - return $range; | |
| 130 | - } | |
| 131 | - } | |
| 132 | - } | |
| 133 | - } | |
| 116 | + /** | |
| 117 | + * try to match against a range that ends with a wildcard * | |
| 118 | + * Example : 192.168.1.* | |
| 119 | + * Example : 192.168.* | |
| 120 | + */ | |
| 121 | + public function matchWildCard() | |
| 122 | +	{ | |
| 123 | +		if ($ranges = array_filter($this->allowedIps, function ($ip) { | |
| 124 | + return substr($ip, -1) === '*'; | |
| 125 | + }) | |
| 126 | +		) { | |
| 127 | +			foreach ($ranges as $range) { | |
| 128 | +				if (substr($this->ip, 0, strlen(substr($range, 0, -1))) === substr($range, 0, -1)) { | |
| 129 | + return $range; | |
| 130 | + } | |
| 131 | + } | |
| 132 | + } | |
| 133 | + } | |
| 134 | 134 | |
| 135 | 135 | } | 
| @@ -77,7 +77,7 @@ discard block | ||
| 77 | 77 | */ | 
| 78 | 78 | public function matchRange() | 
| 79 | 79 |      { | 
| 80 | -        if ($ranges = array_filter($this->allowedIps, function ($ip) { | |
| 80 | +        if ($ranges = array_filter($this->allowedIps, function($ip) { | |
| 81 | 81 | return strstr($ip, '-'); | 
| 82 | 82 | }) | 
| 83 | 83 |          ) { | 
| @@ -100,7 +100,7 @@ discard block | ||
| 100 | 100 | */ | 
| 101 | 101 | public function matchCIDR() | 
| 102 | 102 |      { | 
| 103 | -        if ($ranges = array_filter($this->allowedIps, function ($ip) { | |
| 103 | +        if ($ranges = array_filter($this->allowedIps, function($ip) { | |
| 104 | 104 | return strstr($ip, '/'); | 
| 105 | 105 | }) | 
| 106 | 106 |          ) { | 
| @@ -120,7 +120,7 @@ discard block | ||
| 120 | 120 | */ | 
| 121 | 121 | public function matchWildCard() | 
| 122 | 122 |      { | 
| 123 | -        if ($ranges = array_filter($this->allowedIps, function ($ip) { | |
| 123 | +        if ($ranges = array_filter($this->allowedIps, function($ip) { | |
| 124 | 124 | return substr($ip, -1) === '*'; | 
| 125 | 125 | }) | 
| 126 | 126 |          ) { | 
| @@ -6,102 +6,102 @@ | ||
| 6 | 6 | */ | 
| 7 | 7 | class AdminSecurity extends Security | 
| 8 | 8 |  { | 
| 9 | - private static $allowed_actions = array( | |
| 10 | - 'passwordsent', | |
| 11 | - 'ChangePasswordForm' | |
| 12 | - ); | |
| 9 | + private static $allowed_actions = array( | |
| 10 | + 'passwordsent', | |
| 11 | + 'ChangePasswordForm' | |
| 12 | + ); | |
| 13 | 13 | |
| 14 | - /** | |
| 15 | - * Template thats used to render the pages. | |
| 16 | - * | |
| 17 | - * @config | |
| 18 | - * @var string | |
| 19 | - */ | |
| 20 | - private static $template_main = 'AdminLogin'; | |
| 14 | + /** | |
| 15 | + * Template thats used to render the pages. | |
| 16 | + * | |
| 17 | + * @config | |
| 18 | + * @var string | |
| 19 | + */ | |
| 20 | + private static $template_main = 'AdminLogin'; | |
| 21 | 21 | |
| 22 | - /** | |
| 23 | - * @return mixed | |
| 24 | - */ | |
| 25 | - public function init() | |
| 26 | -    { | |
| 27 | - parent::init(); | |
| 22 | + /** | |
| 23 | + * @return mixed | |
| 24 | + */ | |
| 25 | + public function init() | |
| 26 | +	{ | |
| 27 | + parent::init(); | |
| 28 | 28 | |
| 29 | -        if (Config::inst()->get('IpAccess', 'enabled')) { | |
| 30 | - $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), | |
| 31 | -                Config::inst()->get('IpAccess', 'allowed_ips')); | |
| 32 | -            if (!$ipAccess->hasAccess()) { | |
| 33 | - $reponse = ''; | |
| 34 | -                if (class_exists('ErrorPage', true)) { | |
| 35 | - $response = ErrorPage::response_for(404); | |
| 36 | - } | |
| 37 | - return $this->owner->httpError(404, $response ? $response : 'The requested page could not be found.'); | |
| 38 | - } | |
| 39 | - } | |
| 29 | +		if (Config::inst()->get('IpAccess', 'enabled')) { | |
| 30 | + $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), | |
| 31 | +				Config::inst()->get('IpAccess', 'allowed_ips')); | |
| 32 | +			if (!$ipAccess->hasAccess()) { | |
| 33 | + $reponse = ''; | |
| 34 | +				if (class_exists('ErrorPage', true)) { | |
| 35 | + $response = ErrorPage::response_for(404); | |
| 36 | + } | |
| 37 | + return $this->owner->httpError(404, $response ? $response : 'The requested page could not be found.'); | |
| 38 | + } | |
| 39 | + } | |
| 40 | 40 | |
| 41 | -        if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) { | |
| 42 | - // this prevents loading frontend css and javscript files | |
| 43 | -            Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller'); | |
| 44 | -            Requirements::css('adminlogin/css/style.css'); | |
| 45 | - } | |
| 41 | +		if (Config::inst()->get('AdminLogin', 'UseTheme') !== true) { | |
| 42 | + // this prevents loading frontend css and javscript files | |
| 43 | +			Object::useCustomClass('Page_Controller', 'AdminLoginPage_Controller'); | |
| 44 | +			Requirements::css('adminlogin/css/style.css'); | |
| 45 | + } | |
| 46 | 46 | |
| 47 | -        Object::useCustomClass('MemberLoginForm', 'AdminLoginForm'); | |
| 48 | - } | |
| 47 | +		Object::useCustomClass('MemberLoginForm', 'AdminLoginForm'); | |
| 48 | + } | |
| 49 | 49 | |
| 50 | - /** | |
| 51 | - * @param null $action | |
| 52 | - * @return string | |
| 53 | - */ | |
| 54 | - public function Link($action = null) | |
| 55 | -    { | |
| 56 | - return "AdminSecurity/$action"; | |
| 57 | - } | |
| 50 | + /** | |
| 51 | + * @param null $action | |
| 52 | + * @return string | |
| 53 | + */ | |
| 54 | + public function Link($action = null) | |
| 55 | +	{ | |
| 56 | + return "AdminSecurity/$action"; | |
| 57 | + } | |
| 58 | 58 | |
| 59 | - /** | |
| 60 | - * @return string | |
| 61 | - */ | |
| 62 | - public static function isAdminLogin() | |
| 63 | -    { | |
| 64 | - return strstr(self::getBackUrl(), '/admin/'); | |
| 65 | - } | |
| 59 | + /** | |
| 60 | + * @return string | |
| 61 | + */ | |
| 62 | + public static function isAdminLogin() | |
| 63 | +	{ | |
| 64 | + return strstr(self::getBackUrl(), '/admin/'); | |
| 65 | + } | |
| 66 | 66 | |
| 67 | - /** | |
| 68 | - * @return mixed | |
| 69 | - */ | |
| 70 | - public static function getBackUrl() | |
| 71 | -    { | |
| 72 | -        if (isset($_REQUEST['BackURL'])) { | |
| 73 | - return $_REQUEST['BackURL']; | |
| 74 | -        } elseif (isset($_SESSION['BackURL'])) { | |
| 75 | - return $_SESSION['BackURL']; | |
| 76 | - } | |
| 77 | - } | |
| 67 | + /** | |
| 68 | + * @return mixed | |
| 69 | + */ | |
| 70 | + public static function getBackUrl() | |
| 71 | +	{ | |
| 72 | +		if (isset($_REQUEST['BackURL'])) { | |
| 73 | + return $_REQUEST['BackURL']; | |
| 74 | +		} elseif (isset($_SESSION['BackURL'])) { | |
| 75 | + return $_SESSION['BackURL']; | |
| 76 | + } | |
| 77 | + } | |
| 78 | 78 | |
| 79 | - /** | |
| 80 | - * @param SS_HTTPRequest $request | |
| 81 | - * @return string | |
| 82 | - */ | |
| 83 | - public function passwordsent($request) | |
| 84 | -    { | |
| 85 | - return parent::passwordsent($request); | |
| 86 | - } | |
| 79 | + /** | |
| 80 | + * @param SS_HTTPRequest $request | |
| 81 | + * @return string | |
| 82 | + */ | |
| 83 | + public function passwordsent($request) | |
| 84 | +	{ | |
| 85 | + return parent::passwordsent($request); | |
| 86 | + } | |
| 87 | 87 | |
| 88 | - /** | |
| 89 | - * @see Security::getPasswordResetLink() | |
| 90 | - * We overload this, so we can add the BackURL to the password resetlink | |
| 91 | - */ | |
| 92 | - public static function getPasswordResetLink($member, $autologinToken) | |
| 93 | -    { | |
| 94 | - $autologinToken = urldecode($autologinToken); | |
| 95 | - $selfControllerClass = __CLASS__; | |
| 96 | - $selfController = new $selfControllerClass(); | |
| 97 | -        return $selfController->Link('changepassword') . "?m={$member->ID}&t=$autologinToken"; | |
| 98 | - } | |
| 88 | + /** | |
| 89 | + * @see Security::getPasswordResetLink() | |
| 90 | + * We overload this, so we can add the BackURL to the password resetlink | |
| 91 | + */ | |
| 92 | + public static function getPasswordResetLink($member, $autologinToken) | |
| 93 | +	{ | |
| 94 | + $autologinToken = urldecode($autologinToken); | |
| 95 | + $selfControllerClass = __CLASS__; | |
| 96 | + $selfController = new $selfControllerClass(); | |
| 97 | +		return $selfController->Link('changepassword') . "?m={$member->ID}&t=$autologinToken"; | |
| 98 | + } | |
| 99 | 99 | |
| 100 | - /** | |
| 101 | - * @return ChangePasswordForm | |
| 102 | - */ | |
| 103 | - public function ChangePasswordForm() | |
| 104 | -    { | |
| 105 | - return new ChangePasswordForm($this, 'ChangePasswordForm'); | |
| 106 | - } | |
| 100 | + /** | |
| 101 | + * @return ChangePasswordForm | |
| 102 | + */ | |
| 103 | + public function ChangePasswordForm() | |
| 104 | +	{ | |
| 105 | + return new ChangePasswordForm($this, 'ChangePasswordForm'); | |
| 106 | + } | |
| 107 | 107 | } | 
| @@ -7,14 +7,14 @@ | ||
| 7 | 7 | class AdminLoginExtension extends Extension | 
| 8 | 8 |  { | 
| 9 | 9 | |
| 10 | - // redirect to AdminSecurity, when we are coming from /admin/* | |
| 11 | - public function onBeforeSecurityLogin() | |
| 12 | -    { | |
| 13 | -        if (isset($_GET['BackURL']) && strstr($_GET['BackURL'], '/admin/')) { | |
| 14 | -            if (Controller::curr()->class != 'AdminSecurity') { | |
| 15 | - $link = 'AdminSecurity/login' . '?BackURL=' . urlencode($_GET['BackURL']); | |
| 16 | - return $this->owner->redirect($link); | |
| 17 | - } | |
| 18 | - } | |
| 19 | - } | |
| 10 | + // redirect to AdminSecurity, when we are coming from /admin/* | |
| 11 | + public function onBeforeSecurityLogin() | |
| 12 | +	{ | |
| 13 | +		if (isset($_GET['BackURL']) && strstr($_GET['BackURL'], '/admin/')) { | |
| 14 | +			if (Controller::curr()->class != 'AdminSecurity') { | |
| 15 | + $link = 'AdminSecurity/login' . '?BackURL=' . urlencode($_GET['BackURL']); | |
| 16 | + return $this->owner->redirect($link); | |
| 17 | + } | |
| 18 | + } | |
| 19 | + } | |
| 20 | 20 | } | 
| @@ -5,24 +5,24 @@ | ||
| 5 | 5 | */ | 
| 6 | 6 | class LimitAdminAccessExtension extends Extension | 
| 7 | 7 |  { | 
| 8 | - /** | |
| 9 | - * @return mixed | |
| 10 | - */ | |
| 11 | - public function onBeforeInit() | |
| 12 | -    { | |
| 13 | -        if (Config::inst()->get('IpAccess', 'enabled')) { | |
| 14 | - $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), | |
| 15 | -                Config::inst()->get('IpAccess', 'allowed_ips')); | |
| 8 | + /** | |
| 9 | + * @return mixed | |
| 10 | + */ | |
| 11 | + public function onBeforeInit() | |
| 12 | +	{ | |
| 13 | +		if (Config::inst()->get('IpAccess', 'enabled')) { | |
| 14 | + $ipAccess = new IpAccess($this->owner->getRequest()->getIP(), | |
| 15 | +				Config::inst()->get('IpAccess', 'allowed_ips')); | |
| 16 | 16 | |
| 17 | -            if (!$ipAccess->hasAccess()) { | |
| 18 | -                if (class_exists('ErrorPage', true)) { | |
| 19 | - $response = ErrorPage::response_for(403); | |
| 20 | - } | |
| 17 | +			if (!$ipAccess->hasAccess()) { | |
| 18 | +				if (class_exists('ErrorPage', true)) { | |
| 19 | + $response = ErrorPage::response_for(403); | |
| 20 | + } | |
| 21 | 21 | |
| 22 | - $response = ($response) ? $response : 'The requested page could not be found.'; | |
| 22 | + $response = ($response) ? $response : 'The requested page could not be found.'; | |
| 23 | 23 | |
| 24 | - return $this->owner->httpError(403, $response); | |
| 25 | - } | |
| 26 | - } | |
| 27 | - } | |
| 24 | + return $this->owner->httpError(403, $response); | |
| 25 | + } | |
| 26 | + } | |
| 27 | + } | |
| 28 | 28 | } |