From 23cf79911e20eac981a25dc1c2f839d37f98c296 Mon Sep 17 00:00:00 2001 From: Santo Cariotti Date: Mon, 21 Nov 2022 12:11:38 +0100 Subject: Add fields for users --- server/src/routes/user.rs | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) (limited to 'server/src/routes/user.rs') diff --git a/server/src/routes/user.rs b/server/src/routes/user.rs index 5733871..d0aa056 100644 --- a/server/src/routes/user.rs +++ b/server/src/routes/user.rs @@ -1,14 +1,14 @@ use crate::errors::AppError; use crate::models::{ auth::Claims, - user::{User, UserCreate, UserList}, + user::{User, UserList}, }; use axum::{routing::get, Json, Router}; /// 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("/me", get(get_user)) } @@ -19,21 +19,10 @@ async fn list_users(_: Claims) -> Result>, AppError> { Ok(Json(users)) } -/// Create an user. Checks Authorization token -async fn create_user( - Json(payload): Json, - _: Claims, -) -> Result, AppError> { - let user = User::new(payload.email, payload.password); - let user_new = User::create(user).await?; - - Ok(Json(user_new)) -} - /// Get the user from the `Authorization` header token async fn get_user(claims: Claims) -> Result, AppError> { match User::find_by_id(claims.user_id).await { Ok(user) => Ok(Json(user)), - Err(_) => Err(AppError::NotFound), + Err(_) => Err(AppError::NotFound("User not found".to_string())), } } -- cgit v1.2.3-18-g5258