Code Duplication    Length = 14-16 lines in 2 locations

src/Controller/UsersController.php 2 locations

@@ 534-547 (lines=14) @@
531
                    }
532
533
                    $this->Users->patchEntity($user, $this->request->getParsedBody(), ['validate' => 'settings']);
534
                    if ($this->Users->save($user)) {
535
                        //Logs Event.
536
                        $this->eventManager()->attach(new Logs());
537
                        $event = new Event('Log.User', $this, [
538
                            'user_id' => $user->id,
539
                            'username' => $user->username,
540
                            'user_ip' => $this->request->clientIp(),
541
                            'user_agent' => $this->request->header('User-Agent'),
542
                            'action' => 'user.password.change'
543
                        ]);
544
                        $this->eventManager()->dispatch($event);
545
546
                        $this->Flash->success(__("Your password has been changed !"));
547
                    }
548
                    break;
549
            }
550
        }
@@ 501-516 (lines=16) @@
498
499
                    $this->Users->patchEntity($user, $this->request->getParsedBody(), ['validate' => 'settings']);
500
501
                    if ($this->Users->save($user)) {
502
                        $oldEmail = $this->request->getData('email');
503
504
                        //Logs Event.
505
                        $this->eventManager()->attach(new Logs());
506
                        $event = new Event('Log.User', $this, [
507
                            'user_id' => $user->id,
508
                            'username' => $user->username,
509
                            'user_ip' => $this->request->clientIp(),
510
                            'user_agent' => $this->request->header('User-Agent'),
511
                            'action' => 'user.email'
512
                        ]);
513
                        $this->eventManager()->dispatch($event);
514
515
                        $this->Flash->success(__("Your E-mail has been changed !"));
516
                    }
517
                    break;
518
519
                case "password":