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

daycry / auth / 44317717916

18 Nov 2026 01:49PM UTC coverage: 82.894% (+4.4%) from 78.462%
44317717916

Pull #79

github

web-flow
Merge 7c781daeb into 55dbf61d2
Pull Request #79: feat: security fixes, extension points and auth completion

1214 of 1370 new or added lines in 67 files covered. (88.61%)

12 existing lines in 5 files now uncovered.

6663 of 8038 relevant lines covered (82.89%)

97.52 hits per line

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

78.95
/src/Controllers/ActionController.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\Exceptions\PageNotFoundException;
17
use CodeIgniter\HTTP\RedirectResponse;
18
use CodeIgniter\HTTP\ResponseInterface;
19
use Daycry\Auth\Interfaces\ActionInterface;
20

21
/**
22
 * Class ActionController
23
 *
24
 * A generic controller to handle Authentication Actions.
25
 */
26
class ActionController extends BaseAuthController
27
{
28
    protected ?ActionInterface $action = null;
29

30
    /**
31
     * Perform an initial check if we have a valid action or not.
32
     *
33
     * @param list<string> $params
34
     *
35
     * @return ResponseInterface|string
36
     */
37
    public function _remap(string $method, ...$params)
5 ✔
38
    {
39
        $authenticator = $this->getSessionAuthenticator();
5 ✔
40

41
        // Grab our action instance if one has been set.
42
        $this->action = $authenticator->getAction();
5 ✔
43

44
        if (! $this->action instanceof ActionInterface || ! $this->isRoutableMethod($method)) {
5 ✔
45
            throw new PageNotFoundException();
1 ✔
46
        }
47

48
        if ($this->invalidJsonBody) {
4 ✔
NEW
49
            return $this->authJsonResponse(['status' => 'error', 'message' => 'The request body must be a valid JSON object.'], 400);
×
50
        }
51

52
        if ($this->request->is('json')) {
4 ✔
53
            // Actions share the IncomingRequest contract. Present the parsed
54
            // body to existing/custom actions without mixing query parameters.
55
            $this->request->setGlobal('post', array_map(
4 ✔
56
                static fn ($value) => is_scalar($value) ? $value : null,
4 ✔
57
                $this->authRequestData(),
4 ✔
58
            ));
4 ✔
59
        }
60

61
        $result = $this->{$method}(...$params);
4 ✔
62
        if (! $this->expectsJsonResponse()) {
4 ✔
NEW
63
            return $result;
×
64
        }
65

66
        if ($authenticator->loggedIn()) {
4 ✔
67
            if (($pending = $this->pendingMfaResponse()) !== null) {
3 ✔
68
                return $pending;
2 ✔
69
            }
70

71
            return $this->authJsonResponse([
1 ✔
72
                'status'        => 'success',
1 ✔
73
                'authenticated' => true,
1 ✔
74
                'redirect'      => $result instanceof RedirectResponse ? $result->getHeaderLine('Location') : config('Auth')->loginRedirect(),
1 ✔
75
            ]);
1 ✔
76
        }
77

78
        $error = session()->getFlashdata('error');
1 ✔
79

80
        return $this->authJsonResponse([
1 ✔
81
            'status'        => 'action_required',
1 ✔
82
            'authenticated' => false,
1 ✔
83
            'message'       => is_string($error) ? $error : $authenticator->getPendingMessage(),
1 ✔
84
            'redirect'      => url_to('auth-action-show'),
1 ✔
85
        ], $method === 'verify' || $error !== null ? 422 : 202);
1 ✔
86
    }
87

88
    /**
89
     * Shows the initial screen to the user to start the flow.
90
     * This might be asking for the user's email to reset a password,
91
     * or asking for a cell-number for a 2FA.
92
     *
93
     * @return ResponseInterface|string
94
     */
95
    public function show()
×
96
    {
97
        return $this->action->show();
×
98
    }
99

100
    /**
101
     * Processes the form that was displayed in the previous form.
102
     *
103
     * @return ResponseInterface|string
104
     */
105
    public function handle()
×
106
    {
107
        return $this->action->handle($this->request);
×
108
    }
109

110
    /**
111
     * This handles the response after the user takes action
112
     * in response to the show/handle flow. This might be
113
     * from clicking the 'confirm my email' action or
114
     * following entering a code sent in an SMS.
115
     *
116
     * @return ResponseInterface|string
117
     */
118
    public function verify()
4 ✔
119
    {
120
        return $this->action->verify($this->request);
4 ✔
121
    }
122

123
    /**
124
     * ActionController doesn't use validation rules directly
125
     * as it delegates to action objects
126
     */
127
    protected function getValidationRules(): array
×
128
    {
129
        return [];
×
130
    }
131
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc