• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

daycry / auth / 22527357078

28 Feb 2026 07:22PM UTC coverage: 63.267% (+0.7%) from 62.568%
22527357078

push

github

daycry
Remove PHP 8.1 from PHPUnit CI matrix

Update .github/workflows/phpunit.yml to drop PHP 8.1 from the test matrix. CI will now run PHPUnit only on PHP 8.2 and 8.3, reducing the matrix to current supported versions.

3064 of 4843 relevant lines covered (63.27%)

41.52 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Controllers/ForcePasswordResetController.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of Daycry Auth.
7
 *
8
 * (c) Daycry <daycry9@proton.me>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace Daycry\Auth\Controllers;
15

16
use CodeIgniter\HTTP\RedirectResponse;
17
use CodeIgniter\HTTP\ResponseInterface;
18
use Daycry\Auth\Authentication\Passwords;
19
use Daycry\Auth\Models\UserModel;
20

21
/**
22
 * Handles forced password resets for logged-in users
23
 * whose accounts have been flagged for a mandatory password change.
24
 *
25
 * The ForcePasswordResetFilter redirects users here when
26
 * $user->requiresPasswordReset() returns true.
27
 */
28
class ForcePasswordResetController extends BaseAuthController
29
{
30
    /**
31
     * Displays the force password reset form.
32
     */
33
    public function showView(): ResponseInterface
×
34
    {
35
        if (! auth()->loggedIn()) {
×
36
            return redirect()->route('login');
×
37
        }
38

39
        $content = $this->view(setting('Auth.views')['force-password-reset']);
×
40

41
        return $this->response->setBody($content);
×
42
    }
43

44
    /**
45
     * Handles the force password reset form submission.
46
     */
47
    public function resetAction(): RedirectResponse
×
48
    {
49
        if (! auth()->loggedIn()) {
×
50
            return redirect()->route('login');
×
51
        }
52

53
        $rules = $this->getValidationRules();
×
54

55
        $postData = $this->request->getPost();
×
56

57
        if (! $this->validateRequest($postData, $rules)) {
×
58
            return $this->handleValidationError(config('Auth')->forcePasswordResetRedirect());
×
59
        }
60

61
        $user            = auth()->user();
×
62
        $currentPassword = $this->request->getPost('current_password');
×
63
        $newPassword     = $this->request->getPost('new_password');
×
64

65
        // Verify the current password
66
        /** @var Passwords $passwords */
67
        $passwords = service('passwords');
×
68

69
        if (! $passwords->verify($currentPassword, $user->getPasswordHash())) {
×
70
            return $this->handleError(
×
71
                config('Auth')->forcePasswordResetRedirect(),
×
72
                lang('Auth.invalidCurrentPassword'),
×
73
            );
×
74
        }
75

76
        // Update the password
77
        $user->setPassword($newPassword);
×
78

79
        /** @var UserModel $userModel */
80
        $userModel = model(UserModel::class);
×
81
        $userModel->save($user);
×
82

83
        // Clear the force reset flag
84
        $user->undoForcePasswordReset();
×
85

86
        return $this->handleSuccess(
×
87
            config('Auth')->loginRedirect(),
×
88
            lang('Auth.forceResetSuccess'),
×
89
        );
×
90
    }
91

92
    /**
93
     * Returns the rules that should be used for validation.
94
     *
95
     * @return array<string, string>
96
     */
97
    protected function getValidationRules(): array
×
98
    {
99
        return [
×
100
            'current_password'     => 'required',
×
101
            'new_password'         => 'required|min_length[8]',
×
102
            'new_password_confirm' => 'required|matches[new_password]',
×
103
        ];
×
104
    }
105
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc