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.
3//! All events below may intentionally reject using `capy_core::EventRejection`.
4//! The owning transition rolls back; logout/reset vetoes leave previous credentials
5//! and sessions intact. There is no rejecting reset-request event (existence safety).
6use crate::UserResponse;
7use capy_core::Event;
8
9/// A new user and authenticated session have been inserted, before commit.
10#[derive(Clone)]
11pub struct UserRegistered {
12 /// Safe public user data. Includes PII; do not log the event value.
13 pub user: UserResponse,
14}
15impl Event for UserRegistered {}
16/// The first transition from unverified to verified, before commit.
17/// Replay does not emit another event. Verification proof is application-owned.
18#[derive(Clone)]
19pub struct EmailVerified {
20 /// Verified user ID; no email/token is carried.
21 pub user_id: i64,
22}
23impl Event for EmailVerified {}
24/// Password verification succeeded and a session was rotated, before commit.
25#[derive(Clone)]
26pub struct LoginSucceeded {
27 /// Authenticated user ID.
28 pub user_id: i64,
29}
30impl Event for LoginSucceeded {}
31/// An authenticated session was actually deleted, before commit.
32#[derive(Clone)]
33pub struct LoggedOut {
34 /// User whose session was removed.
35 pub user_id: i64,
36}
37impl Event for LoggedOut {}
38/// A reset token was consumed, password changed and sessions revoked, before commit.
39#[derive(Clone)]
40pub struct PasswordResetCompleted {
41 /// User whose credentials changed.
42 pub user_id: i64,
43}
44impl Event for PasswordResetCompleted {}