Code Duplication    Length = 14-16 lines in 2 locations

src/Controller/UsersController.php 2 locations

@@ 484-499 (lines=16) @@
481
482
                    $this->Users->patchEntity($user, $this->request->data(), ['validate' => 'settings']);
483
484
                    if ($this->Users->save($user)) {
485
                        $oldEmail = $this->request->data['email'];
486
487
                        //Logs Event.
488
                        $this->eventManager()->attach(new Logs());
489
                        $event = new Event('Log.User', $this, [
490
                            'user_id' => $user->id,
491
                            'username' => $user->username,
492
                            'user_ip' => $this->request->clientIp(),
493
                            'user_agent' => $this->request->header('User-Agent'),
494
                            'action' => 'user.email'
495
                        ]);
496
                        $this->eventManager()->dispatch($event);
497
498
                        $this->Flash->success(__("Your E-mail has been changed !"));
499
                    }
500
                    break;
501
502
                case "password":
@@ 517-530 (lines=14) @@
514
                    }
515
516
                    $this->Users->patchEntity($user, $this->request->data(), ['validate' => 'settings']);
517
                    if ($this->Users->save($user)) {
518
                        //Logs Event.
519
                        $this->eventManager()->attach(new Logs());
520
                        $event = new Event('Log.User', $this, [
521
                            'user_id' => $user->id,
522
                            'username' => $user->username,
523
                            'user_ip' => $this->request->clientIp(),
524
                            'user_agent' => $this->request->header('User-Agent'),
525
                            'action' => 'user.password.change'
526
                        ]);
527
                        $this->eventManager()->dispatch($event);
528
529
                        $this->Flash->success(__("Your password has been changed !"));
530
                    }
531
                    break;
532
            }
533
        }