From ce62e3bac6a8acea555731d6222028c511dd9019 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Tue, 13 Sep 2022 14:49:15 +0200 Subject: Drop user creation --- src/models/user.rs | 8 -------- src/routes/user.rs | 15 ++------------- 2 files changed, 2 insertions(+), 21 deletions(-) diff --git a/src/models/user.rs b/src/models/user.rs index 55abc97..ba2df8f 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -28,14 +28,6 @@ pub struct UserList { is_staff: Option, } -/// Payload used for user creation -#[derive(Deserialize)] -pub struct UserCreate { - pub email: String, - pub username: String, - pub password: String, -} - impl User { /// By default an user has id = 0. It is not created yet pub fn new(email: String, username: String, password: String) -> Self { diff --git a/src/routes/user.rs b/src/routes/user.rs index 4ac994c..8c2ec0e 100644 --- a/src/routes/user.rs +++ b/src/routes/user.rs @@ -1,7 +1,7 @@ use crate::errors::AppError; use crate::models::{ auth::Claims, - user::{User, UserCreate, UserList}, + user::{User, UserList}, }; use crate::pagination::Pagination; use axum::{ @@ -14,7 +14,7 @@ use serde::Serialize; /// Create routes for `/v1/users/` namespace pub fn create_route() -> Router { Router::new() - .route("/", get(list_users).post(create_user)) + .route("/", get(list_users)) .route("/:id", get(get_user)) } @@ -36,17 +36,6 @@ async fn list_users( Ok(Json(UserPagination { count, results })) } -/// Create an user. Checks Authorization token -async fn create_user( - Json(payload): Json, - _: Claims, -) -> Result, AppError> { - let user = User::new(payload.email, payload.username, payload.password); - let user_new = User::create(user).await?; - - Ok(Json(user_new)) -} - /// Get an user with id = `user_id`. Checks Authorization token async fn get_user(Path(user_id): Path, _: Claims) -> Result, AppError> { match User::find_by_id(user_id).await { -- cgit v1.2.3-71-g8e6c