From 942865b6ac10fafa79b83badebe79986ce61dedd Mon Sep 17 00:00:00 2001 From: yenicelik Date: Wed, 18 Jan 2023 14:00:30 +0100 Subject: [PATCH] also removing login from cache. should add tests for all these cases --- .../bin/web3_proxy_cli/change_user_admin_status.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/web3_proxy/src/bin/web3_proxy_cli/change_user_admin_status.rs b/web3_proxy/src/bin/web3_proxy_cli/change_user_admin_status.rs index 3058cb7e..1be5ea86 100644 --- a/web3_proxy/src/bin/web3_proxy_cli/change_user_admin_status.rs +++ b/web3_proxy/src/bin/web3_proxy_cli/change_user_admin_status.rs @@ -1,12 +1,13 @@ use anyhow::Context; use argh::FromArgs; -use entities::{admin, user}; +use entities::{admin, login, user}; use ethers::types::Address; use log::{debug, info}; use migration::sea_orm::{ self, ActiveModelTrait, ColumnTrait, DatabaseConnection, EntityTrait, ModelTrait, IntoActiveModel, QueryFilter, }; +use web3_proxy::frontend::errors::FrontendErrorResponse; /// change a user's admin status. eiter they are an admin, or they aren't #[derive(FromArgs, PartialEq, Eq, Debug)] @@ -59,6 +60,14 @@ impl ChangeUserAdminStatusSubCommand { _ => {} } + // Remove any user logins from the database (incl. bearer tokens) + let delete_result = login::Entity::delete_many() + .filter(login::Column::UserId.eq(user.id)) + .exec(db_conn) + .await; + + debug!("cleared modified logins: {:?}", delete_result); + Ok(()) } }