nil_payload/request/
auth.rs1use bon::Builder;
5use nil_core::player::PlayerId;
6use nil_crypto::password::Password;
7use nil_server_types::auth::Token;
8use serde::{Deserialize, Serialize};
9
10#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
11#[serde(rename_all = "camelCase")]
12#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
13#[cfg_attr(feature = "typescript", ts(export, optional_fields = nullable))]
14pub struct AuthorizeRequest {
15 #[builder(into)]
16 pub player: PlayerId,
17 #[serde(default)]
18 #[builder(into)]
19 pub password: Option<Password>,
20}
21
22#[derive(Builder, Clone, Debug, Deserialize, Serialize)]
23#[serde(rename_all = "camelCase")]
24#[cfg_attr(feature = "typescript", derive(ts_rs::TS))]
25#[cfg_attr(feature = "typescript", ts(export))]
26pub struct ValidateTokenRequest {
27 #[builder(start_fn, into)]
28 pub token: Token,
29}
30
31impl<T> From<T> for ValidateTokenRequest
32where
33 T: AsRef<str>,
34{
35 fn from(token: T) -> Self {
36 Self { token: Token::new(token) }
37 }
38}