Code Duplication    Length = 8-11 lines in 3 locations

src/controllers/TotpController.php 3 locations

@@ 61-68 (lines=8) @@
58
    {
59
        /** @var MfaIdentityInterface $user */
60
        $user = Yii::$app->user->identity;
61
        if ($user->getTotpSecret()) {
62
            Yii::$app->session->setFlash(
63
                'error',
64
                Yii::t('mfa', 'Two-factor authentication is already enabled. Disable first.')
65
            );
66
67
            return empty($back) ? $this->goHome() : $this->deferredRedirect($back);
68
        }
69
70
        $model = new InputForm();
71
        $secret = $this->module->getTotp()->getSecret();
@@ 97-107 (lines=11) @@
94
                    );
95
96
                    return empty($back) ? $this->goBack() : $this->deferredRedirect($back);
97
                } else {
98
                    Yii::$app->session->setFlash(
99
                        'error',
100
                        Yii::t(
101
                            'mfa',
102
                            'Sorry, we have failed to enable two-factor authentication.'
103
                        )
104
                    );
105
106
                    return empty($back) ? $this->goHome() : $this->deferredRedirect($back);
107
                }
108
            } else {
109
                $model->addError(
110
                    'code',
@@ 123-130 (lines=8) @@
120
121
    public function actionCodes(array $codes, $back = null)
122
    {
123
        if (Yii::$app->request->post('mfa-codes-saved')) {
124
            Yii::$app->session->setFlash(
125
                'success',
126
                Yii::t('mfa', 'Two-factor authentication successfully enabled.')
127
            );
128
129
            return empty($back) ? $this->goBack() : $this->deferredRedirect($back);
130
        }
131
132
        return $this->render('codes', compact('codes'));
133
    }