refactor(backend): drop redundant LoftError from Result return types

This commit is contained in:
2026-06-13 17:31:03 +03:00
parent 2616896ecb
commit 450b3fdf52
3 changed files with 16 additions and 15 deletions

View File

@@ -5,13 +5,14 @@ use axum::{
};
use tower_cookies::Cookies;
use crate::{ctx::Ctx, error::LoftError, model::UserRepository, web::AUTH_TOKEN};
use crate::{
ctx::Ctx,
error::{LoftError, Result},
model::UserRepository,
web::AUTH_TOKEN,
};
pub async fn mw_require_auth(
ctx: Result<Ctx, LoftError>,
req: Request,
next: Next,
) -> Result<Response, LoftError> {
pub async fn mw_require_auth(ctx: Result<Ctx>, req: Request, next: Next) -> Result<Response> {
ctx?;
Ok(next.run(req).await)
@@ -22,7 +23,7 @@ pub async fn mw_ctx_resolver(
cookies: Cookies,
mut req: Request,
next: Next,
) -> Result<Response, LoftError> {
) -> Result<Response> {
let auth_token = cookies.get(AUTH_TOKEN).map(|c| c.value().to_string());
let result_ctx = match auth_token {
@@ -46,7 +47,7 @@ impl<S: Send + Sync> FromRequestParts<S> for Ctx {
) -> Result<Self, Self::Rejection> {
parts
.extensions
.get::<Result<Ctx, LoftError>>()
.get::<Result<Ctx>>()
.ok_or(LoftError::AuthFailCtxNotInRequestExt)?
.clone()
}