also removing login from cache. should add tests for all these cases

This commit is contained in:
yenicelik 2023-01-18 14:00:30 +01:00
parent bbe9061402
commit 61bd7d6e35

@ -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(())
}
}