From e864d2653d50ba1c920776aaa14a1625c9fc9da4 Mon Sep 17 00:00:00 2001 From: Tolmachev Igor Date: Wed, 22 Oct 2025 17:00:28 +0300 Subject: Add invite tokens --- src/routers/account.rs | 30 +++++++++++------------------- 1 file changed, 11 insertions(+), 19 deletions(-) (limited to 'src/routers/account.rs') diff --git a/src/routers/account.rs b/src/routers/account.rs index 51ce911..e39327a 100644 --- a/src/routers/account.rs +++ b/src/routers/account.rs @@ -2,30 +2,23 @@ use axum::extract::State; use chrono::{DateTime, Duration, Utc}; use entity::users::{self}; use sea_orm::{ - ActiveModelTrait, ActiveValue::Set, ColumnTrait, DatabaseConnection, EntityTrait, - IntoActiveModel, ModelTrait, QueryFilter, + ActiveModelTrait, ActiveValue::Set, ColumnTrait, EntityTrait, IntoActiveModel, ModelTrait, + QueryFilter, }; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; use utoipa_axum::{router::OpenApiRouter, routes}; use crate::{ - ApiError, ApiResult, AppState, ClientError, GlobalResponses, JwtClaims, ServerError, - SuccessResponse, create_jwt, create_password, + ApiResult, AppState, ClientError, GlobalResponses, JwtClaims, ServerError, SuccessResponse, + create_jwt, create_password, extract::{ApiJson, Auth}, models::Account, tags::ACCOUNT, + util::username_exists, validate_password, }; -async fn username_exists(username: &str, db: &DatabaseConnection) -> Result { - Ok(users::Entity::find() - .filter(users::Column::Username.eq(username)) - .one(db) - .await? - .is_some()) -} - #[derive(Serialize, ToSchema)] #[schema(description = "Authorization token information")] struct Token { @@ -205,7 +198,7 @@ async fn login( } #[utoipa::path( - put, + patch, path = "/update/password", tag = ACCOUNT, summary = "Change password", @@ -214,7 +207,7 @@ async fn login( responses( ( status = 200, body = SuccessResponse, - description = "Success response with the updated account data" + description = "Success response with the changed account data" ), GlobalResponses ), @@ -238,7 +231,7 @@ async fn update_password( } #[utoipa::path( - put, + patch, path = "/update/username", tag = ACCOUNT, summary = "Change username", @@ -247,7 +240,7 @@ async fn update_password( responses( ( status = 200, body = SuccessResponse, - description = "Success response with the updated account data" + description = "Success response with the changed account data" ), GlobalResponses ), @@ -273,7 +266,7 @@ async fn update_username( } #[utoipa::path( - put, + patch, path = "/update/name", tag = ACCOUNT, summary = "Change name", @@ -282,7 +275,7 @@ async fn update_username( responses( ( status = 200, body = SuccessResponse, - description = "Success response with the updated account data" + description = "Success response with the changed account data" ), GlobalResponses ), @@ -332,7 +325,6 @@ async fn delete( } user.clone().delete(&state.db).await?; - Ok(SuccessResponse::ok(user.into())) } -- cgit v1.2.3