From 3aae8ec6da9c1a1a5dffb4e8cd2ffc2560e5b9f1 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Thu, 15 Sep 2022 16:31:30 +0200 Subject: Add `JsonCreate` trait which is a Json with 201 status --- src/routes/auth.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'src/routes/auth.rs') diff --git a/src/routes/auth.rs b/src/routes/auth.rs index 5c9b293..7cd16ad 100644 --- a/src/routes/auth.rs +++ b/src/routes/auth.rs @@ -3,6 +3,7 @@ use crate::models::{ auth::{AuthBody, Claims, LoginCredentials, SignUpForm}, user::User, }; +use crate::routes::JsonCreate; use axum::{routing::post, Json, Router}; /// Create routes for `/v1/auth/` namespace @@ -27,7 +28,7 @@ async fn make_login(Json(payload): Json) -> Result) -> Result, AppError> { +async fn signup(Json(payload): Json) -> Result, AppError> { if payload.password1 != payload.password2 { return Err(AppError::BadRequest( "The inserted passwords do not match".to_string(), @@ -51,5 +52,5 @@ async fn signup(Json(payload): Json) -> Result, AppEr let claims = Claims::new(user.id); let token = claims.get_token()?; - Ok(Json(AuthBody::new(token))) + Ok(JsonCreate(AuthBody::new(token))) } -- cgit v1.2.3-71-g8e6c