Code Duplication    Length = 37-37 lines in 2 locations

src/library/ThreemaGateway/ControllerAdmin/Login.php 1 location

@@ 11-47 (lines=37) @@
8
 * @license MIT
9
 */
10
11
class ThreemaGateway_ControllerAdmin_Login extends XFCP_ThreemaGateway_ControllerAdmin_Login
12
{
13
    /**
14
     * Passes the provider ID to the TFA model to enable customized behaviour.
15
     *
16
     * @return XenForo_ControllerResponse_View
17
     */
18
    public function actionTwoStep()
19
    {
20
        /** @var string $providerId */
21
        $providerId = $this->_input->filterSingle('provider', XenForo_Input::STRING);
22
23
        /** @var bool $isThreemaGwProvider whether this is a provider handled by us */
24
        $isThreemaGwProvider = in_array($providerId, ThreemaGateway_Constants::TFA_PROVIDER_ARRAY);
25
26
        if ($isThreemaGwProvider) {
27
            $this->_getTfaModel()->threemagwSetProviderId($providerId);
28
        } else {
29
            // to be sure, better reset the value if we do not handle the things
30
            // (when caching or so might retain this model)
31
            $this->_getTfaModel()->threemagwSetProviderId(null);
32
        }
33
34
        /** @var XenForo_ControllerResponse_View $parent original response */
35
        $parent = parent::actionTwoStep();
36
37
        return $parent;
38
    }
39
40
    /**
41
     * @return XenForo_Model_Tfa
42
     */
43
    protected function _getTfaModel()
44
    {
45
        return $this->getModelFromCache('XenForo_Model_Tfa');
46
    }
47
}
48

src/library/ThreemaGateway/ControllerPublic/Login.php 1 location

@@ 11-47 (lines=37) @@
8
 * @license MIT
9
 */
10
11
class ThreemaGateway_ControllerPublic_Login extends XFCP_ThreemaGateway_ControllerPublic_Login
12
{
13
    /**
14
     * Passes the provider ID to the TFa model to enable customized behaviour.
15
     *
16
     * @return XenForo_ControllerResponse_View
17
     */
18
    public function actionTwoStep()
19
    {
20
        /** @var string $providerId */
21
        $providerId = $this->_input->filterSingle('provider', XenForo_Input::STRING);
22
23
        /** @var bool $isThreemaGwProvider whether this is a provider handled by us */
24
        $isThreemaGwProvider = in_array($providerId, ThreemaGateway_Constants::TFA_PROVIDER_ARRAY);
25
26
        if ($isThreemaGwProvider) {
27
            $this->_getTfaModel()->threemagwSetProviderId($providerId);
28
        } else {
29
            // to be sure, better reset the value if we do not handle the things
30
            // (otherwise caching or so might retain this model)
31
            $this->_getTfaModel()->threemagwSetProviderId(null);
32
        }
33
34
        /** @var XenForo_ControllerResponse_View $parent original response */
35
        $parent = parent::actionTwoStep();
36
37
        return $parent;
38
    }
39
40
    /**
41
     * @return XenForo_Model_Tfa
42
     */
43
    protected function _getTfaModel()
44
    {
45
        return $this->getModelFromCache('XenForo_Model_Tfa');
46
    }
47
}
48