Code Duplication    Length = 8-9 lines in 2 locations

src/Controller/UsersController.php 2 locations

@@ 632-640 (lines=9) @@
629
        $this->Users->patchEntity($user, $data);
630
        $success = $this->Users->save($user);
631
632
        if ($success) {
633
            $this->Flash->set(
634
                __('change_password_success'),
635
                ['element' => 'success']
636
            );
637
            $this->redirect(['controller' => 'users', 'action' => 'edit', $id]);
638
639
            return;
640
        }
641
642
        $errors = $user->getErrors();
643
        if (!empty($errors)) {
@@ 676-683 (lines=8) @@
673
        if ($this->getRequest()->is('post')) {
674
            $this->Users->patchEntity($user, $this->getRequest()->getData(), ['fields' => 'password']);
675
676
            if ($this->Users->save($user)) {
677
                $this->Flash->set(
678
                    __('user.pw.set.s'),
679
                    ['element' => 'success']
680
                );
681
682
                return $this->redirect(['controller' => 'users', 'action' => 'edit', $id]);
683
            }
684
            $errors = $user->getErrors();
685
            if (!empty($errors)) {
686
                $this->Flash->set(