PasswordController::postChangePassword()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 5
Ratio 38.46 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 5
loc 13
rs 9.4285
cc 2
eloc 7
nc 2
nop 2
1
<?php
2
3
namespace App\Controllers\Auth;
4
5
use App\Controllers\Controller;
6
7
class PasswordController extends Controller
8
{
9
    public function getChangePassword($request, $response)
10
    {
11
        return $this->view->render($response, 'auth/password/change.twig');
12
    }
13
14
    public function postChangePassword($request, $response)
15
    {
16 View Code Duplication
        if ($this->validator->validatePasswordChangeForm($request)->getErrorsCount() > 0) {
17
            $_SESSION['errors'] = $this->validator->getErrors();
18
            return $response->withRedirect($this->router->pathFor('auth.password.change'));
19
        }
20
21
        $this->auth->user()->setPassword($request->getParam('password1'));
22
23
        $this->flash->addMessage('success', 'Hasło zostało zmienione');
24
25
        return $response->withRedirect($this->router->pathFor('auth.password.change'));
26
    }
27
}
28