summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSanto Cariotti <santo@dcariotti.me>2022-09-13 12:49:15 +0000
committerSanto Cariotti <santo@dcariotti.me>2022-09-13 12:49:15 +0000
commitce62e3bac6a8acea555731d6222028c511dd9019 (patch)
tree1f24ef946d8d618ec554129c9a1b4061b3a5a3de /src
parent9f7571078ac7fbffe1ca343e245f41646b907bc9 (diff)
Drop user creation
Diffstat (limited to 'src')
-rw-r--r--src/models/user.rs8
-rw-r--r--src/routes/user.rs15
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<bool>,
}
-/// 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<UserCreate>,
- _: Claims,
-) -> Result<Json<UserList>, 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<i32>, _: Claims) -> Result<Json<UserList>, AppError> {
match User::find_by_id(user_id).await {