use bon::Builder;
use nil_core::player::PlayerId;
use nil_crypto::password::Password;
use nil_server_types::auth::Token;
use serde::{Deserialize, Serialize};
#[cfg(feature = "typescript")]
use ts_rs::TS;
#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export, optional_fields = nullable))]
pub struct AuthorizeRequest {
pub player: PlayerId,
#[serde(default)]
pub password: Option<Password>,
}
#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(feature = "typescript", derive(TS))]
#[cfg_attr(feature = "typescript", ts(export))]
pub struct ValidateTokenRequest {
pub token: Token,
}
impl<T> From<T> for ValidateTokenRequest
where
T: AsRef<str>,
{
fn from(token: T) -> Self {
Self { token: Token::new(token) }
}
}