summaryrefslogtreecommitdiff
path: root/src/routes/user.rs
diff options
context:
space:
mode:
authorDaniel Hader <[email protected]>2026-05-30 10:10:17 -0500
committerDaniel Hader <[email protected]>2026-05-30 10:10:17 -0500
commit929be68e691c1c4015fc6874111b19b9f5d68c02 (patch)
treeffc4ecb9c63d8dc242c33d69a592dc093dcfd122 /src/routes/user.rs
parent772c7844c4ca1de632f64eb9428e8e97eea64ac1 (diff)
registration page, me endpoint, and minor content tweaks
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 }))
+}