From aea640a64c044906cc6660ec8538291aecbaed38 Mon Sep 17 00:00:00 2001 From: Radical Date: Thu, 1 May 2025 19:18:44 +0200 Subject: [PATCH] style: use the same response for login/register --- src/api/v1/auth/login.rs | 12 +++++------- src/api/v1/auth/register.rs | 7 +------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/src/api/v1/auth/login.rs b/src/api/v1/auth/login.rs index 81d1370..d484c4e 100644 --- a/src/api/v1/auth/login.rs +++ b/src/api/v1/auth/login.rs @@ -16,10 +16,9 @@ struct LoginInformation { } #[derive(Serialize)] -struct Response { - access_token: String, - expires_in: u64, - refresh_token: String, +pub struct Response { + pub access_token: String, + pub refresh_token: String, } const MAX_SIZE: usize = 262_144; @@ -111,9 +110,8 @@ async fn login(data: actix_web::web::Data, uuid: String, request_password: } return HttpResponse::Ok().json(Response { - access_token: "bogus".to_string(), - expires_in: 0, - refresh_token: "bogus".to_string(), + access_token, + refresh_token, }) } diff --git a/src/api/v1/auth/register.rs b/src/api/v1/auth/register.rs index 250872f..24ea0bf 100644 --- a/src/api/v1/auth/register.rs +++ b/src/api/v1/auth/register.rs @@ -8,6 +8,7 @@ use uuid::Uuid; use argon2::{password_hash::{rand_core::OsRng, SaltString}, PasswordHasher}; use crate::{crypto::{generate_access_token, generate_refresh_token}, Data}; +use super::login::Response; #[derive(Deserialize)] struct AccountInformation { @@ -48,12 +49,6 @@ impl Default for ResponseError { } } -#[derive(Serialize)] -struct Response { - access_token: String, - refresh_token: String, -} - const MAX_SIZE: usize = 262_144; #[post("/register")]