added initial roadmap and implementation
This commit is contained in:
64
auth/src/models.rs
Normal file
64
auth/src/models.rs
Normal file
@@ -0,0 +1,64 @@
|
||||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use sqlx::FromRow;
|
||||
use uuid::Uuid;
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, FromRow, Clone)]
|
||||
pub struct User {
|
||||
pub id: Uuid,
|
||||
pub email: String,
|
||||
#[serde(skip)]
|
||||
pub encrypted_password: String,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
pub last_sign_in_at: Option<DateTime<Utc>>,
|
||||
pub raw_app_meta_data: serde_json::Value,
|
||||
pub raw_user_meta_data: serde_json::Value,
|
||||
pub is_super_admin: Option<bool>,
|
||||
pub confirmed_at: Option<DateTime<Utc>>,
|
||||
pub email_confirmed_at: Option<DateTime<Utc>>,
|
||||
pub phone: Option<String>,
|
||||
pub phone_confirmed_at: Option<DateTime<Utc>>,
|
||||
pub confirmation_token: Option<String>,
|
||||
pub recovery_token: Option<String>,
|
||||
pub email_change_token_new: Option<String>,
|
||||
pub email_change: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Validate)]
|
||||
pub struct SignUpRequest {
|
||||
#[validate(email)]
|
||||
pub email: String,
|
||||
#[validate(length(min = 6, message = "Password must be at least 6 characters"))]
|
||||
pub password: String,
|
||||
pub data: Option<serde_json::Value>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Validate)]
|
||||
pub struct SignInRequest {
|
||||
#[validate(email)]
|
||||
pub email: String,
|
||||
pub password: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct AuthResponse {
|
||||
pub access_token: String,
|
||||
pub token_type: String,
|
||||
pub expires_in: i64,
|
||||
pub refresh_token: String,
|
||||
pub user: User,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, FromRow)]
|
||||
pub struct RefreshToken {
|
||||
pub id: i64, // BigSerial
|
||||
pub token: String,
|
||||
pub user_id: Uuid,
|
||||
pub revoked: bool,
|
||||
pub created_at: DateTime<Utc>,
|
||||
pub updated_at: DateTime<Utc>,
|
||||
pub parent: Option<String>,
|
||||
pub session_id: Option<Uuid>,
|
||||
}
|
||||
Reference in New Issue
Block a user