Coverage for bc/kwai-bc-identity/src/kwai_bc_identity/tokens/user_log.py: 100%
19 statements
« prev ^ index » next coverage.py v7.11.0, created at 2024-01-01 00:00 +0000
« prev ^ index » next coverage.py v7.11.0, 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
10from kwai_bc_identity.tokens.refresh_token import RefreshTokenEntity
11from kwai_bc_identity.tokens.value_objects import IpAddress, OpenId
12from kwai_bc_identity.users.user_account import UserAccountEntity
15class UserLogIdentifier(IntIdentifier):
16 """Identifier for a UserLog entity."""
19@dataclass(kw_only=True, eq=False, slots=True, frozen=True)
20class UserLogEntity(DataclassEntity):
21 """A UserLog entity.
23 Attributes:
24 success: Was this user logged in successfully?
25 email: Email used to log in.
26 user_account: User account used to log in.
27 refresh_token: Refresh token created for the login.
28 client_ip: Client IP address
29 user_agent: User agent string
30 openid: OpenId information
31 remark: A remark
32 created_at: Timestamp of login
33 """
35 ID: ClassVar[Type] = UserLogIdentifier
37 success: bool = False
38 email: str = ""
39 user_account: UserAccountEntity | None = None
40 refresh_token: RefreshTokenEntity | None = None
41 client_ip: IpAddress
42 user_agent: str
43 openid: OpenId = field(default_factory=OpenId)
44 remark: str = ""
45 created_at: Timestamp = field(default_factory=Timestamp.create_now)