58 lines
1.2 KiB
Rust
58 lines
1.2 KiB
Rust
use crate::service::account::entity::Account as AccountEntity;
|
|
use derive_more::Constructor;
|
|
use serde::{Deserialize, Serialize};
|
|
use uuid::Uuid;
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct CreateAccount {
|
|
pub name: String,
|
|
pub email: Option<String>,
|
|
pub password: String,
|
|
}
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct Login {
|
|
pub name: String,
|
|
pub password: String,
|
|
}
|
|
|
|
#[derive(Constructor, Serialize)]
|
|
pub struct Account {
|
|
pub email: Option<String>,
|
|
pub name: String,
|
|
pub id: Uuid,
|
|
}
|
|
|
|
#[derive(Constructor, Serialize)]
|
|
pub struct Tokens {
|
|
pub refresh: String,
|
|
pub access: String,
|
|
}
|
|
|
|
#[derive(Constructor, Serialize)]
|
|
pub struct AccountCreated {
|
|
pub account: Account,
|
|
pub tokens: Tokens,
|
|
}
|
|
|
|
#[derive(Constructor, Serialize, Deserialize)]
|
|
pub struct AccessTokenClaims {
|
|
pub exp: i64,
|
|
pub sub: String,
|
|
pub iat: i64,
|
|
}
|
|
|
|
#[derive(Constructor, Serialize, Deserialize)]
|
|
pub struct RefreshTokenClaims {
|
|
pub exp: i64,
|
|
pub sub: String,
|
|
pub iat: i64,
|
|
pub refresh_token_id: Uuid,
|
|
}
|
|
|
|
impl From<AccountEntity> for Account {
|
|
fn from(entity: AccountEntity) -> Self {
|
|
Account::new(entity.email, entity.username, entity.id)
|
|
}
|
|
}
|