Skip to content

Commit efd5e18

Browse files
committed
clean up user exporting and fix utoipa
I had broken the user login part of rapidoc a while back. This fixes it
1 parent 41eb901 commit efd5e18

File tree

7 files changed

+10
-11
lines changed

7 files changed

+10
-11
lines changed

domain/src/lib.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ pub use entity_api::{
99
query::{IntoQueryFilterMap, QueryFilterMap},
1010
};
1111

12-
// Re-exports from `entity`
13-
pub use entity_api::user::{AuthSession, Backend, Credentials};
12+
// Re-exports from `entity` crate
1413
pub use entity_api::{
1514
actions, agreements, coachees, coaches, coaching_relationships, coaching_sessions, jwts, notes,
1615
organizations, overarching_goals, users, Id,

domain/src/user.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use entity_api::mutate;
33
use sea_orm::DatabaseConnection;
44
use sea_orm::IntoActiveModel;
55

6-
pub use entity_api::user::{create, find_by_email, find_by_id};
6+
pub use entity_api::user::{create, find_by_email, find_by_id, AuthSession, Backend, Credentials};
77

88
pub async fn update(
99
db: &DatabaseConnection,

entity_api/src/user.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ pub struct Backend {
6969
}
7070

7171
#[derive(Debug, Clone, ToSchema, IntoParams, Deserialize)]
72-
#[schema(as = entity_api::user::Credentials)] // OpenAPI schema
72+
#[schema(as = domain::user::Credentials)] // OpenAPI schema
7373
pub struct Credentials {
7474
pub email: String,
7575
pub password: String,

web/src/controller/user_session_controller.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::controller::ApiResponse;
22
use axum::{http::StatusCode, response::IntoResponse, Form, Json};
3-
use domain::{AuthSession, Credentials};
3+
use domain::user::{AuthSession, Credentials};
44
use log::*;
55
use serde::Deserialize;
66
use serde_json::json;
@@ -37,7 +37,7 @@ pub async fn protected(auth_session: AuthSession) -> impl IntoResponse {
3737
#[utoipa::path(
3838
post,
3939
path = "/login",
40-
request_body(content = Credentials, content_type = "application/x-www-form-urlencoded"),
40+
request_body(content = domain::user::Credentials, content_type = "application/x-www-form-urlencoded"),
4141
responses(
4242
(status = 200, description = "Logs in and returns session authentication cookie"),
4343
(status = 401, description = "Unauthorized"),
@@ -94,7 +94,7 @@ security(
9494
("cookie_auth" = [])
9595
)
9696
)]
97-
pub async fn logout(mut auth_session: domain::AuthSession) -> impl IntoResponse {
97+
pub async fn logout(mut auth_session: AuthSession) -> impl IntoResponse {
9898
debug!("UserSessionController::logout()");
9999
match auth_session.logout().await {
100100
Ok(_) => StatusCode::OK.into_response(),

web/src/extractors/authenticated_user.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ where
1919
// This extractor wraps the AuthSession extractor from axum_login. It extracts the user from the AuthSession and returns an AuthenticatedUser.
2020
// If the user is authenticated. If the user is not authenticated, it returns an Unauthorized error.
2121
async fn from_request_parts(parts: &mut Parts, state: &S) -> Result<Self, Self::Rejection> {
22-
let session: domain::AuthSession = AuthSession::from_request_parts(parts, state)
22+
let session: domain::user::AuthSession = AuthSession::from_request_parts(parts, state)
2323
.await
2424
.map_err(|(status, msg)| (status, msg.to_string()))?;
2525
match session.user {

web/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use axum_login::{
66
tower_sessions::{Expiry, SessionManagerLayer},
77
AuthManagerLayerBuilder,
88
};
9-
use domain::Backend;
9+
use domain::user::Backend;
1010
use tower_sessions::session_store::ExpiredDeletion;
1111
use tower_sessions_sqlx_store::PostgresStore;
1212

web/src/router.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ use axum::{
55
Router,
66
};
77
use axum_login::login_required;
8-
use domain::Backend;
8+
use domain::user::Backend;
99
use tower_http::services::ServeDir;
1010

1111
use crate::controller::{
@@ -76,7 +76,7 @@ use self::organization::coaching_relationship_controller;
7676
domain::organizations::Model,
7777
domain::overarching_goals::Model,
7878
domain::users::Model,
79-
domain::Credentials,
79+
domain::user::Credentials,
8080
params::user::UpdateUserParams,
8181
8282
)

0 commit comments

Comments
 (0)