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

daycry / auth / 21003933517

14 Jan 2026 05:39PM UTC coverage: 66.786% (+0.2%) from 66.555%
21003933517

push

github

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

Add OAuth 2.0 support and improve authentication extensibility

201 of 278 new or added lines in 24 files covered. (72.3%)

7 existing lines in 4 files now uncovered.

2246 of 3363 relevant lines covered (66.79%)

33.3 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()) instanceof RedirectResponse) {
×
29
            return $redirect;
×
30
        }
31

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

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

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
48
        $rules    = $this->getValidationRules();
×
49
        $postData = $this->request->getPost();
×
50

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

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

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

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
85
        $url = config('Auth')->logoutRedirect();
×
86

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

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