mirror of
https://github.com/thanipro/Axum-Rust-Rest-Api-Template
synced 2024-11-10 06:04:16 +00:00
Custom debug for struct with sensitive data
This commit is contained in:
parent
1fab7958b3
commit
e57b007dd0
3 changed files with 25 additions and 6 deletions
|
@ -1,12 +1,12 @@
|
|||
use serde::{Deserialize, Serialize};
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct TokenReadDto {
|
||||
pub token: String,
|
||||
pub iat: i64,
|
||||
pub exp: i64,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize)]
|
||||
#[derive(Clone, Serialize, Deserialize)]
|
||||
pub struct TokenClaimsDto {
|
||||
pub sub: i32,
|
||||
pub email: String,
|
||||
|
|
|
@ -3,7 +3,7 @@ use chrono::{DateTime, Utc};
|
|||
use serde::{Deserialize, Serialize};
|
||||
use validator::Validate;
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Validate)]
|
||||
#[derive(Clone, Serialize, Deserialize, Validate)]
|
||||
pub struct UserLoginDto {
|
||||
#[validate(email(message = "Email is not valid"))]
|
||||
pub email: String,
|
||||
|
@ -15,7 +15,7 @@ pub struct UserLoginDto {
|
|||
pub password: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Serialize, Deserialize, Validate)]
|
||||
#[derive(Clone, Serialize, Deserialize, Validate)]
|
||||
pub struct UserRegisterDto {
|
||||
#[validate(email(message = "Email is not valid"))]
|
||||
pub email: String,
|
||||
|
@ -61,3 +61,22 @@ impl UserReadDto {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for UserLoginDto {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("User")
|
||||
.field("email", &self.email)
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for UserRegisterDto {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_struct("User")
|
||||
.field("first_name", &self.first_name)
|
||||
.field("last_name", &self.last_name)
|
||||
.field("user_name", &self.user_name)
|
||||
.field("email", &self.email)
|
||||
.finish()
|
||||
}
|
||||
}
|
|
@ -1,7 +1,7 @@
|
|||
use chrono::{DateTime, Utc};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Clone, Debug, Deserialize, Serialize, sqlx::FromRow)]
|
||||
#[derive(Clone, Deserialize, Serialize, sqlx::FromRow)]
|
||||
pub struct User {
|
||||
pub id: i32,
|
||||
pub first_name: Option<String>,
|
||||
|
|
Loading…
Reference in a new issue