summaryrefslogtreecommitdiff
path: root/src/routes/user.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/routes/user.rs')
-rw-r--r--src/routes/user.rs16
1 files changed, 13 insertions, 3 deletions
diff --git a/src/routes/user.rs b/src/routes/user.rs
index f64cb39..157cf09 100644
--- a/src/routes/user.rs
+++ b/src/routes/user.rs
@@ -1,14 +1,14 @@
use axum::extract::{Json, State};
use axum::http::StatusCode;
use axum::response::IntoResponse;
-use serde::Deserialize;
+use serde::{Deserialize, Serialize};
use crate::AppState;
-use crate::auth::hash_password;
+use crate::routes::auth::{AuthUser, hash_password};
use super::errors::RouteError;
#[derive(Deserialize)]
-pub struct CreateUserRequest {
+pub(crate) struct CreateUserRequest {
email: String,
username: String,
password: String,
@@ -42,3 +42,13 @@ pub async fn create_user(
return Ok((StatusCode::CREATED, Json(user)));
}
+#[derive(Serialize)]
+struct MeResponse {
+ username: String,
+}
+
+pub async fn me(
+ AuthUser(claims): AuthUser,
+) -> Result<impl IntoResponse, RouteError> {
+ Ok(Json(MeResponse { username: claims.username }))
+}