PasswordController::getChangePassword()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
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