using Tiku.Domain.Tenancy;
namespace Tiku.Application.Auth;
///
/// 认证令牌对。
///
/// 用于访问 API 的 JWT access token。
/// 用于刷新会话的 refresh token,服务端只保存哈希。
/// access token 过期时间。
/// refresh token 过期时间。
public sealed record AuthTokenPair(
string AccessToken,
string RefreshToken,
DateTimeOffset AccessTokenExpiresAt,
DateTimeOffset RefreshTokenExpiresAt);
///
/// 当前登录租户成员摘要。
///
/// 租户 ID。
/// 租户名称。
/// 当前用户在租户内的角色。
/// 租户成员状态。
public sealed record TenantMembershipSummary(
Guid TenantId,
string TenantName,
TenantRole Role,
MembershipStatus Status);
///
/// 登录成功后的应用层用户信息。
///
/// 用户 ID。
/// 手机号。
/// 邮箱。
/// 用户显示名称。
/// 当前登录租户成员摘要。
/// 认证令牌对。
public sealed record AuthenticatedUser(
Guid UserId,
string? Phone,
string? Email,
string? Name,
TenantMembershipSummary Tenant,
AuthTokenPair Tokens);
public sealed record PasswordLoginRequest(
Guid TenantId,
string Phone,
string Password,
string? IpAddress,
string? UserAgent);
public sealed record SmsLoginRequest(
Guid TenantId,
string Phone,
string Code,
string? IpAddress,
string? UserAgent);
public sealed record WechatLoginRequest(
Guid TenantId,
string Code,
string? IpAddress,
string? UserAgent);
public sealed record RefreshSessionRequest(
string RefreshToken,
string? IpAddress,
string? UserAgent);
public sealed record LogoutSessionRequest(
string RefreshToken);
public sealed record SmsSendResult(
Guid VerificationId,
DateTimeOffset ExpiresAt);
public sealed record SendSmsCodeRequest(
Guid TenantId,
string Phone,
SmsPurpose Purpose,
string? IpAddress,
string? UserAgent);