use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use crate::modules::auth::services::auth_service::Session;
/// Arguments of the `auth_register` tool.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct RegisterRequest {
/// Display name, 1 to 100 characters.
pub name: String,
pub email: String,
/// 8 to 256 characters.
pub password: String,
}
/// Arguments of the `auth_login` tool.
#[derive(Debug, Deserialize, JsonSchema)]
pub struct LoginRequest {
pub email: String,
pub password: String,
}
/// The authenticated user, as returned by `auth_me`.
#[derive(Debug, Serialize, JsonSchema)]
pub struct MeResponse {
pub id: i64,
pub name: String,
pub email: String,
pub roles: Vec<String>,
}
/// Result of `auth_register` and `auth_login`. Send `access_token` as
/// `Authorization: Bearer <access_token>` on later MCP requests.
#[derive(Debug, Serialize, JsonSchema)]
pub struct TokenResponse {
pub token_type: &'static str,
pub access_token: String,
pub expires_at: String,
pub user: MeResponse,
}
/// Result of `auth_logout`.
#[derive(Debug, Serialize, JsonSchema)]
pub struct LogoutResponse {
pub revoked: bool,
}
impl From<Session> for TokenResponse {
fn from(session: Session) -> Self {
Self {
token_type: "Bearer",
access_token: session.token,
expires_at: session.expires_at,
user: MeResponse {
id: session.user.id,
name: session.user.name,
email: session.user.email,
roles: session.roles,
},
}
}
}