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

miaoxing / app / 12451993872

22 Dec 2024 06:23AM UTC coverage: 22.581%. Remained the same
12451993872

push

github

twinh
feat(app): 记录用户登录日志

0 of 19 new or added lines in 2 files covered. (0.0%)

11 existing lines in 1 file now uncovered.

42 of 186 relevant lines covered (22.58%)

2.9 hits per line

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

0.0
/src/Service/LoginLogModel.php
1
<?php
2

3
namespace Miaoxing\App\Service;
4

5
use Miaoxing\App\Metadata\LoginLogTrait;
6
use Miaoxing\Plugin\BaseModel;
7
use Miaoxing\Plugin\Model\HasAppIdTrait;
8
use Miaoxing\Plugin\Model\IpTrait;
9
use Miaoxing\Plugin\Model\ModelTrait;
10
use Miaoxing\Plugin\Model\ReqQueryTrait;
11
use Miaoxing\Plugin\Service\User;
12

13
/**
14
 * @mixin \StrPropMixin
15
 */
16
class LoginLogModel extends BaseModel
17
{
18
    use HasAppIdTrait;
19
    use IpTrait;
20
    use LoginLogTrait;
21
    use ModelTrait;
22
    use ReqQueryTrait;
23

24
    public const TYPE_LOGIN = 1;
25

26
    public const TYPE_LOGIN_FAILED = 2;
27

28
    public const TYPE_LOGOUT = 3;
29

30
    /**
31
     * 记录登录日志
32
     *
33
     * @param array $data
34
     * @svc
35
     */
36
    protected function log(array $data)
37
    {
NEW
38
        $user = User::cur();
×
NEW
39
        $this->saveAttributes(array_merge([
×
NEW
40
            'userId' => $user->id ?? 0,
×
NEW
41
            'username' => $user->username ?? '',
×
NEW
42
            'userAgent' => $this->str->cut($this->req->getHeader('USER_AGENT'), 255),
×
NEW
43
        ], $data));
×
44
    }
45
}
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