AdminLoginExtension::onBeforeSecurityLogin()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 0
1
<?php
2
3
/**
4
 * Custom Admin Login form screen.
5
 *
6
 * This login screen get also ip based access protection when enabled
7
 *
8
 * @property Security $owner
9
 */
10
class AdminLoginExtension extends Extension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    /**
13
     * Redirect to AdminSecurity, when we are coming from /admin/*.
14
     *
15
     * @return SS_HTTPResponse|void
16
     */
17
    public function onBeforeSecurityLogin()
18
    {
19
        $backUrl = $this->owner->getRequest()->getVar('BackURL');
20
        if (strstr($backUrl, '/admin/')) {
21
            if (Controller::curr()->class != 'AdminSecurity') {
22
                $link = 'AdminSecurity/login'.'?BackURL='.urlencode($backUrl);
23
24
                return $this->owner->redirect($link);
25
            }
26
        }
27
    }
28
}
29