Coverage for src/kwai/modules/identity/tokens/user_log.py: 100%
21 statements
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.6.10, created at 2024-01-01 00:00 +0000
1"""Module that defines the UserLog entity."""
3from dataclasses import dataclass, field
4from typing import ClassVar, Type
6from kwai.core.domain.entity import DataclassEntity
7from kwai.core.domain.value_objects.identifier import IntIdentifier
8from kwai.core.domain.value_objects.timestamp import Timestamp
9from kwai.modules.identity.tokens.refresh_token import RefreshTokenEntity
10from kwai.modules.identity.tokens.value_objects import IpAddress, OpenId
11from kwai.modules.identity.users.user_account import UserAccountEntity
14class UserLogIdentifier(IntIdentifier):
15 """Identifier for a UserLog entity."""
18@dataclass(kw_only=True, eq=False, slots=True, frozen=True)
19class UserLogEntity(DataclassEntity):
20 """A UserLog entity.
22 Attributes:
23 success: Was this user logged in successfully?
24 email: Email used to log in.
25 user_account: User account used to log in.
26 refresh_token: Refresh token created for the login.
27 client_ip: Client IP address
28 user_agent: User agent string
29 openid: OpenId information
30 remark: A remark
31 created_at: Timestamp of login
32 """
34 ID: ClassVar[Type] = UserLogIdentifier
36 success: bool = False
37 email: str = ""
38 user_account: UserAccountEntity | None = None
39 refresh_token: RefreshTokenEntity | None = None
40 client_ip: IpAddress
41 user_agent: str
42 openid: OpenId = field(default_factory=OpenId)
43 remark: str = ""
44 created_at: Timestamp = field(default_factory=Timestamp.create_now)