Skip to main content

capy_auth/
events.rs

1//! Authentication transaction events. No credentials are included. External delivery
2//! must use transactional Jobs/outboxes; a database commit can still fail afterward.
3use crate::UserResponse;
4use capy_core::Event;
5
6/// A new user and authenticated session have been inserted, before commit.
7#[derive(Clone)]
8pub struct UserRegistered {
9    /// Safe public user data. Includes PII; do not log the event value.
10    pub user: UserResponse,
11}
12impl Event for UserRegistered {}
13/// The first transition from unverified to verified, before commit.
14/// Replay does not emit another event. Verification proof is application-owned.
15#[derive(Clone)]
16pub struct EmailVerified {
17    /// Verified user ID; no email/token is carried.
18    pub user_id: i64,
19}
20impl Event for EmailVerified {}
21/// Password verification succeeded and a session was rotated, before commit.
22#[derive(Clone)]
23pub struct LoginSucceeded {
24    /// Authenticated user ID.
25    pub user_id: i64,
26}
27impl Event for LoginSucceeded {}
28/// An authenticated session was actually deleted, before commit.
29#[derive(Clone)]
30pub struct LoggedOut {
31    /// User whose session was removed.
32    pub user_id: i64,
33}
34impl Event for LoggedOut {}
35/// A reset token was consumed, password changed and sessions revoked, before commit.
36#[derive(Clone)]
37pub struct PasswordResetCompleted {
38    /// User whose credentials changed.
39    pub user_id: i64,
40}
41impl Event for PasswordResetCompleted {}