broken only push user data
This commit is contained in:
34
server/src/auth/models.rs
Normal file
34
server/src/auth/models.rs
Normal file
@@ -0,0 +1,34 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
use uuid::Uuid;
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Debug, Validate, Deserialize)]
|
||||
pub struct RegisterRequest {
|
||||
#[validate(length(min = 3, max = 30))]
|
||||
pub username: String,
|
||||
#[validate(email)]
|
||||
pub email: String,
|
||||
#[validate(length(min = 8))]
|
||||
pub password: String,
|
||||
pub password_confirmation: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
pub struct AuthResponse {
|
||||
pub id: Uuid,
|
||||
pub username: String,
|
||||
pub email: String,
|
||||
pub role: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum AuthError {
|
||||
#[error("Passwords do not match")]
|
||||
PasswordMismatch,
|
||||
#[error("User already exists")]
|
||||
UserExists,
|
||||
#[error("Database error: {0}")]
|
||||
DatabaseError(String),
|
||||
#[error("Hashing error: {0}")]
|
||||
HashingError(String),
|
||||
}
|
||||
Reference in New Issue
Block a user