From 2420f1e75d54a5f209b0267715f078a369d81eb1 Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Sun, 23 Mar 2025 15:58:33 -0400 Subject: Rename the `login` module to `user`. --- src/login/routes/password/post.rs | 54 --------------------------------------- 1 file changed, 54 deletions(-) delete mode 100644 src/login/routes/password/post.rs (limited to 'src/login/routes/password/post.rs') diff --git a/src/login/routes/password/post.rs b/src/login/routes/password/post.rs deleted file mode 100644 index 4723754..0000000 --- a/src/login/routes/password/post.rs +++ /dev/null @@ -1,54 +0,0 @@ -use axum::{ - extract::{Json, State}, - http::StatusCode, - response::{IntoResponse, Response}, -}; - -use crate::{ - app::App, - clock::RequestedAt, - error::Internal, - login::{Login, Password}, - token::{ - app, - extract::{Identity, IdentityCookie}, - }, -}; - -pub async fn handler( - State(app): State, - RequestedAt(now): RequestedAt, - identity: Identity, - cookie: IdentityCookie, - Json(request): Json, -) -> Result<(IdentityCookie, Json), Error> { - let (login, secret) = app - .tokens() - .change_password(&identity.login, &request.password, &request.to, &now) - .await - .map_err(Error)?; - let cookie = cookie.set(secret); - Ok((cookie, Json(login))) -} - -#[derive(serde::Deserialize)] -pub struct Request { - pub password: Password, - pub to: Password, -} - -#[derive(Debug, thiserror::Error)] -#[error(transparent)] -pub struct Error(#[from] pub app::LoginError); - -impl IntoResponse for Error { - fn into_response(self) -> Response { - let Self(error) = self; - match error { - app::LoginError::Rejected => { - (StatusCode::BAD_REQUEST, "invalid name or password").into_response() - } - other => Internal::from(other).into_response(), - } - } -} -- cgit v1.2.3