axum_supabase_auth/auth/
types.rs

1use serde::Deserialize;
2use std::fmt::{Debug, Formatter};
3use time::OffsetDateTime;
4
5#[derive(Clone, Deserialize, PartialEq, Eq)]
6pub struct Session {
7    pub access_token: String,
8    pub token_type: String,
9    pub expires_in: i32,
10    #[serde(with = "time::serde::timestamp")]
11    pub expires_at: OffsetDateTime,
12    pub refresh_token: String,
13    pub user: User,
14}
15
16impl Debug for Session {
17    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
18        f.debug_struct("Session")
19            .field("access_token", &"[redacted]")
20            .field("token_type", &self.token_type)
21            .field("expires_in", &self.expires_in)
22            .field("expires_at", &self.expires_at)
23            .field("refresh_token", &"[redacted]")
24            .field("user", &self.user)
25            .finish()
26    }
27}
28
29#[derive(Debug)]
30pub enum EmailOrPhone {
31    Email(String),
32    Phone(String),
33}
34
35#[derive(Debug, Clone, Deserialize, PartialEq, Eq)]
36pub struct User {
37    pub id: String,
38    pub email: String,
39    pub aud: String,
40    pub role: String,
41    pub email_confirmed_at: Option<String>,
42    pub phone: String,
43    pub last_sign_in_at: Option<String>,
44    pub created_at: String,
45    pub updated_at: String,
46}
47
48#[derive(Debug)]
49pub struct UserAttributes {
50    pub email: String,
51    pub password: String,
52    pub data: serde_json::Value,
53}
54
55#[derive(Debug, Clone, Deserialize)]
56pub struct UserList {
57    pub users: Vec<User>,
58}
59
60#[derive(Debug, Deserialize)]
61pub struct UserUpdate {
62    pub id: String,
63    pub email: String,
64    pub new_email: String,
65    pub email_change_sent_at: String,
66    pub created_at: String,
67    pub updated_at: String,
68}
69
70#[derive(Debug)]
71pub struct OAuthRequest {
72    pub provider: String,
73    pub redirect_to: String,
74}
75
76#[derive(Debug)]
77pub struct OAuthResponse {
78    pub supabase_url: String,
79    pub csrf_token: String,
80}