Skip to content

Commit 156e444

Browse files
committed
Refactor the backend API to match what the frontend already correctly expects for logout --> delete /user_sessions/:id
1 parent 8f84cba commit 156e444

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

web/src/controller/user_session_controller.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,10 @@ pub async fn login(
8181
/// Logs the user out of the platform by destroying their session.
8282
/// Test this with curl: curl -v \
8383
/// --header "Cookie: id=07bbbe54-bd35-425f-8e63-618a8d8612df" \
84-
/// --request GET http://localhost:4000/logout
84+
/// --request DELETE http://localhost:4000/user_sessions/:id
8585
#[utoipa::path(
8686
get,
87-
path = "/logout",
87+
path = "/delete",
8888
responses(
8989
(status = 200, description = "Successfully logged out"),
9090
(status = 401, description = "Unauthorized"),
@@ -94,8 +94,8 @@ security(
9494
("cookie_auth" = [])
9595
)
9696
)]
97-
pub async fn logout(mut auth_session: AuthSession) -> impl IntoResponse {
98-
debug!("UserSessionController::logout()");
97+
pub async fn delete(mut auth_session: AuthSession) -> impl IntoResponse {
98+
trace!("UserSessionController::delete()");
9999
match auth_session.logout().await {
100100
Ok(_) => StatusCode::OK.into_response(),
101101
Err(_) => StatusCode::INTERNAL_SERVER_ERROR.into_response(),

web/src/router.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use self::organization::coaching_relationship_controller;
6666
overarching_goal_controller::update_status,
6767
user_controller::update,
6868
user_session_controller::login,
69-
user_session_controller::logout,
69+
user_session_controller::delete,
7070
jwt_controller::generate_collab_token,
7171
),
7272
components(
@@ -345,7 +345,7 @@ pub fn user_routes(app_state: AppState) -> Router {
345345
pub fn user_session_protected_routes() -> Router {
346346
Router::new()
347347
.route("/protected", get(user_session_controller::protected))
348-
.route("/logout", delete(user_session_controller::logout))
348+
.route("/user_sessions/:id", delete(user_session_controller::delete))
349349
.route_layer(login_required!(Backend, login_url = "/login"))
350350
}
351351

0 commit comments

Comments
 (0)