• 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/LoginController.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\Events\Events;
17
use CodeIgniter\HTTP\RedirectResponse;
18
use CodeIgniter\HTTP\ResponseInterface;
19
use Daycry\Auth\Validation\ValidationRules;
20

21
class LoginController extends BaseAuthController
22
{
23
    /**
24
     * Displays the form the login to the site.
25
     */
26
    public function loginView(): ResponseInterface
×
27
    {
28
        // Check if already logged in
29
        if (($redirect = $this->redirectIfLoggedIn()) instanceof RedirectResponse) {
×
30
            return $redirect;
×
31
        }
32

33
        // Check if there's a pending post-auth action
34
        if ($this->hasPostAuthAction()) {
×
35
            return $this->redirectToAuthAction();
×
36
        }
37

38
        $content = $this->view(setting('Auth.views')['login']);
×
39

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

43
    /**
44
     * Attempts to log the user in.
45
     */
46
    public function loginAction(): RedirectResponse
×
47
    {
48
        // Validate input
49
        $rules    = $this->getValidationRules();
×
50
        $postData = $this->request->getPost();
×
51

52
        if (! $this->validateRequest($postData, $rules)) {
×
53
            return $this->handleValidationError(config('Auth')->loginRoute());
×
54
        }
55

56
        // Extract credentials and remember preference
57
        $credentials = $this->extractLoginCredentials();
×
58
        $remember    = $this->shouldRememberUser();
×
59

60
        // Fire pre-login event (listeners can cancel or enrich credentials)
61
        Events::trigger('pre-login', $credentials);
×
62

63
        // Attempt authentication
64
        $authenticator = $this->getSessionAuthenticator();
×
65
        $result        = $authenticator->remember($remember)->attempt($credentials);
×
66

67
        return $this->handleAuthResult($result, config('Auth')->loginRoute());
×
68
    }
69

70
    /**
71
     * Returns the rules that should be used for validation.
72
     *
73
     * @return         array<string, array<string, list<string>|string>>
74
     * @phpstan-return array<string, array<string, string|list<string>>>
75
     */
76
    protected function getValidationRules(): array
×
77
    {
78
        $rules = new ValidationRules();
×
79

80
        return $rules->getLoginRules();
×
81
    }
82

83
    /**
84
     * Logs the current user out.
85
     */
86
    public function logoutAction(): RedirectResponse
×
87
    {
88
        // Capture logout redirect URL before auth logout
89
        $url = config('Auth')->logoutRedirect();
×
90

91
        auth()->logout();
×
92

93
        return $this->handleSuccess($url, lang('Auth.successLogout'));
×
94
    }
95
}
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