From d77d0b98de16a7df6d350673c82db176438c1d70 Mon Sep 17 00:00:00 2001 From: Jackson Chadfield Date: Sun, 1 Oct 2023 10:32:18 +1300 Subject: [PATCH] rename logout route --- backend/src/api/api_docs.rs | 2 +- backend/src/api/auth/controllers.rs | 6 +++--- backend/src/api/auth/mod.rs | 6 +++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/backend/src/api/api_docs.rs b/backend/src/api/api_docs.rs index b1f8d8d..eda98b4 100644 --- a/backend/src/api/api_docs.rs +++ b/backend/src/api/api_docs.rs @@ -12,7 +12,7 @@ use utoipa::{Modify, OpenApi}; paths( auth_routes::register, auth_routes::login, - auth_routes::logout, + auth_routes::delete_refresh_token, auth_routes::refresh_token, auth_routes::get_user, ), diff --git a/backend/src/api/auth/controllers.rs b/backend/src/api/auth/controllers.rs index 2889609..3f9a81d 100644 --- a/backend/src/api/auth/controllers.rs +++ b/backend/src/api/auth/controllers.rs @@ -118,8 +118,8 @@ pub async fn login( /// /// This will invalidate the refresh token #[utoipa::path( - post, - path = "/auth/logout", + delete, + path = "/auth/refresh_token", tag = "auth", security( ("api_token" = []) @@ -128,7 +128,7 @@ pub async fn login( (status = 204, description = "Logout successful"), ) )] -pub async fn logout( +pub async fn delete_refresh_token( State(state): State, Extension(user): Extension, ) -> Result { diff --git a/backend/src/api/auth/mod.rs b/backend/src/api/auth/mod.rs index 948e1fa..ca80122 100644 --- a/backend/src/api/auth/mod.rs +++ b/backend/src/api/auth/mod.rs @@ -1,8 +1,8 @@ use super::middleware::auth; use crate::AppState; -use axum::routing::{get, post}; +use axum::routing::{delete, get, post}; use axum::{middleware, Router}; -use controllers::{get_user, login, logout, refresh_token, register}; +use controllers::{delete_refresh_token, get_user, login, refresh_token, register}; pub mod controllers; pub mod models; @@ -10,7 +10,7 @@ mod utils; pub fn get_router(state: AppState) -> Router { Router::new() - .route("/logout", post(logout)) + .route("/logout", delete(delete_refresh_token)) .route("/user", get(get_user)) .route_layer(middleware::from_fn_with_state(state.clone(), auth)) .route("/register", post(register))