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

daycry / auth / 16343465380

17 Jul 2025 11:07AM UTC coverage: 59.224% (-0.6%) from 59.854%
16343465380

push

github

web-flow
Merge pull request #23 from daycry/development

Improvements

57 of 292 new or added lines in 16 files covered. (19.52%)

6 existing lines in 4 files now uncovered.

1939 of 3274 relevant lines covered (59.22%)

22.81 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\HTTP\RedirectResponse;
17
use CodeIgniter\HTTP\ResponseInterface;
18
use Daycry\Auth\Validation\ValidationRules;
19

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

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

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

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

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

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

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

59
        // Attempt authentication
NEW
60
        $authenticator = $this->getSessionAuthenticator();
×
NEW
61
        $result        = $authenticator->remember($remember)->attempt($credentials);
×
62

NEW
63
        return $this->handleAuthResult($result, config('Auth')->loginRoute());
×
64
    }
65

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

76
        return $rules->getLoginRules();
×
77
    }
78

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

87
        auth()->logout();
×
88

NEW
89
        return $this->handleSuccess($url, lang('Auth.successLogout'));
×
90
    }
91
}
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