Code Duplication    Length = 5-5 lines in 5 locations

src/Controller/TfaController.php 5 locations

@@ 41-45 (lines=5) @@
38
            ])
39
            ->first();
40
41
        if ($user->two_factor_auth_enabled == true) {
42
            $this->Flash->error(__('You have already set-up the Two-factor authentication.'));
43
44
            return $this->redirect(['controller' => 'users', 'action' => 'security']);
45
        }
46
    }
47
48
    /**
@@ 76-80 (lines=5) @@
73
            ])
74
            ->first();
75
76
        if ($user->two_factor_auth_enabled == true) {
77
            $this->Flash->error(__('You have already set-up the Two-factor authentication.'));
78
79
            return $this->redirect(['controller' => 'users', 'action' => 'security']);
80
        }
81
82
        $tfa = new TwoFactorAuth('Xeta');
83
@@ 203-207 (lines=5) @@
200
            ])
201
            ->first();
202
203
        if (is_null($user) || $user->two_factor_auth_enabled == false) {
204
            $this->Flash->error(__('The Two-factor authentication is not enabled !'));
205
206
            return $this->redirect(['controller' => 'users', 'action' => 'security']);
207
        }
208
209
        $user->two_factor_auth_enabled = false;
210
        $this->Users->save($user);
@@ 265-269 (lines=5) @@
262
            ])
263
            ->first();
264
265
        if (is_null($user) || $user->two_factor_auth_enabled == false) {
266
            $this->Flash->error(__('The Two-factor authentication is not enabled !'));
267
268
            return $this->redirect(['controller' => 'users', 'action' => 'security']);
269
        }
270
271
        $this->set(compact('user'));
272
    }
@@ 296-300 (lines=5) @@
293
            ])
294
            ->first();
295
296
        if (is_null($user) || $user->two_factor_auth_enabled == false) {
297
            $this->Flash->error(__('The Two-factor authentication is not enabled !'));
298
299
            return $this->redirect(['controller' => 'users', 'action' => 'security']);
300
        }
301
302
        $tfa = $this->UsersTwoFactorAuth
303
            ->find()