Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions web/src/controller/user_session_controller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,10 @@ pub async fn login(
/// Logs the user out of the platform by destroying their session.
/// Test this with curl: curl -v \
/// --header "Cookie: id=07bbbe54-bd35-425f-8e63-618a8d8612df" \
/// --request GET http://localhost:4000/logout
/// --request DELETE http://localhost:4000/user_sessions/:id
#[utoipa::path(
get,
path = "/logout",
path = "/delete",
responses(
(status = 200, description = "Successfully logged out"),
(status = 401, description = "Unauthorized"),
Expand All @@ -94,8 +94,8 @@ security(
("cookie_auth" = [])
)
)]
pub async fn logout(mut auth_session: AuthSession) -> impl IntoResponse {
debug!("UserSessionController::logout()");
pub async fn delete(mut auth_session: AuthSession) -> impl IntoResponse {
trace!("UserSessionController::delete()");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

curious on the choice to use trace! over debug ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking that function call console output is kind of the definition of trace and perhaps we are ready to start migrating the rest over to use trace as well?

match auth_session.logout().await {
Ok(_) => StatusCode::OK.into_response(),
Err(_) => StatusCode::INTERNAL_SERVER_ERROR.into_response(),
Expand Down
7 changes: 5 additions & 2 deletions web/src/router.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ use self::organization::coaching_relationship_controller;
overarching_goal_controller::update_status,
user_controller::update,
user_session_controller::login,
user_session_controller::logout,
user_session_controller::delete,
jwt_controller::generate_collab_token,
),
components(
Expand Down Expand Up @@ -345,7 +345,10 @@ pub fn user_routes(app_state: AppState) -> Router {
pub fn user_session_protected_routes() -> Router {
Router::new()
.route("/protected", get(user_session_controller::protected))
.route("/logout", delete(user_session_controller::logout))
.route(
"/user_sessions/:id",
delete(user_session_controller::delete),
)
.route_layer(login_required!(Backend, login_url = "/login"))
}

Expand Down
Loading