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

daycry / auth / 22527658769

28 Feb 2026 07:41PM UTC coverage: 63.267% (-3.6%) from 66.864%
22527658769

push

github

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

Implement TOTP 2FA, JWT auth, device session tracking, and docs overhaul

465 of 1168 new or added lines in 52 files covered. (39.81%)

129 existing lines in 46 files now uncovered.

3064 of 4843 relevant lines covered (63.27%)

41.53 hits per line

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

0.0
/src/Controllers/Admin/LogsController.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\Admin;
15

16
use CodeIgniter\HTTP\RedirectResponse;
17
use CodeIgniter\I18n\Time;
18
use Daycry\Auth\Models\LoginModel;
19

20
/**
21
 * Admin Logs Controller — view and purge login attempt logs.
22
 */
23
class LogsController extends BaseAdminController
24
{
25
    /**
26
     * Paginated login log with optional filters.
27
     */
NEW
28
    public function index(): string
×
29
    {
30
        /** @var LoginModel $loginModel */
NEW
31
        $loginModel = model(LoginModel::class);
×
32

NEW
33
        $q       = (string) $this->request->getGet('q');       // identifier / email
×
NEW
34
        $success = $this->request->getGet('success');           // '1' | '0' | ''
×
NEW
35
        $from    = (string) $this->request->getGet('from');     // Y-m-d
×
NEW
36
        $to      = (string) $this->request->getGet('to');       // Y-m-d
×
37

NEW
38
        if ($q !== '') {
×
NEW
39
            $loginModel->like('identifier', $q);
×
40
        }
41

NEW
42
        if ($success === '1' || $success === '0') {
×
NEW
43
            $loginModel->where('success', (int) $success);
×
44
        }
45

NEW
46
        if ($from !== '') {
×
NEW
47
            $loginModel->where('date >=', $from . ' 00:00:00');
×
48
        }
49

NEW
50
        if ($to !== '') {
×
NEW
51
            $loginModel->where('date <=', $to . ' 23:59:59');
×
52
        }
53

NEW
54
        $logs = $loginModel
×
NEW
55
            ->orderBy('id', 'DESC')
×
NEW
56
            ->paginate(30, 'default');
×
57

NEW
58
        return $this->view('Daycry\\Auth\\Views\\admin\\logs\\index', [
×
NEW
59
            'logs'    => $logs,
×
NEW
60
            'pager'   => $loginModel->pager,
×
NEW
61
            'q'       => $q,
×
NEW
62
            'success' => $success,
×
NEW
63
            'from'    => $from,
×
NEW
64
            'to'      => $to,
×
NEW
65
        ]);
×
66
    }
67

68
    /**
69
     * Delete login records older than N days.
70
     */
NEW
71
    public function purge(): RedirectResponse
×
72
    {
NEW
73
        $days = max(1, (int) $this->request->getPost('days'));
×
74

75
        /** @var LoginModel $loginModel */
NEW
76
        $loginModel = model(LoginModel::class);
×
77

NEW
78
        $cutoff = Time::now()->subDays($days)->format('Y-m-d H:i:s');
×
NEW
79
        $loginModel->where('date <', $cutoff)->delete();
×
80

NEW
81
        return redirect()->route('admin-logs')
×
NEW
82
            ->with('message', "Logs older than {$days} day(s) have been purged.");
×
83
    }
84
}
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