From c545838f3c8a27175f52ba133fc220a34fa798e1 Mon Sep 17 00:00:00 2001 From: Pierre HUBERT Date: Wed, 12 May 2021 18:50:02 +0200 Subject: [PATCH] Can sign out user --- src/controllers/admin/admin_account_controller.rs | 7 +++++++ src/routes.rs | 1 + 2 files changed, 8 insertions(+) diff --git a/src/controllers/admin/admin_account_controller.rs b/src/controllers/admin/admin_account_controller.rs index 5e33cfa..fe3b79f 100644 --- a/src/controllers/admin/admin_account_controller.rs +++ b/src/controllers/admin/admin_account_controller.rs @@ -39,6 +39,13 @@ pub fn auth_with_reset_token(r: &mut HttpRequestHandler) -> RequestResult { r.set_response(AdminAuthSuccess::new(token)) } +/// Sign out current admin +pub fn sign_out(r: &mut HttpRequestHandler) -> RequestResult { + admin_access_token_helper::destroy(r.admin_id()?)?; + + r.ok() +} + /// Get current admin ID pub fn get_admin_id(r: &mut HttpRequestHandler) -> RequestResult { r.set_response(AdminIDAPI::new(r.admin_id()?)) diff --git a/src/routes.rs b/src/routes.rs index 4a7411d..819591f 100644 --- a/src/routes.rs +++ b/src/routes.rs @@ -349,6 +349,7 @@ pub fn get_routes() -> Vec { // Admin accounts controller Route::limited_admin_post_without_login("/admin/accounts/auth_options", Box::new(admin_account_controller::get_auth_options), LimitPolicy::FAILURE(5)), Route::limited_admin_post_without_login("/admin/accounts/auth_with_reset_token", Box::new(admin_account_controller::auth_with_reset_token), LimitPolicy::FAILURE(5)), + Route::admin_post("/admin/accounts/sign_out", Box::new(admin_account_controller::get_admin_id)), Route::admin_post("/admin/accounts/id", Box::new(admin_account_controller::get_admin_id)), Route::admin_post("/admin/accounts/info", Box::new(admin_account_controller::get_admin_info)), ]