use crate::protos::auth as proto; use crate::{AuthService, KenAuthError}; impl AuthService { #[allow(clippy::too_many_arguments)] pub async fn change_password( &self, user_id: i64, old_password_hash: &str, new_password_hash: &str, keep_session_id: &str, client_ip: &str, ) -> Result { let request_id = crate::share::audit::current_request_id(); self.change_password_inner( Some(request_id.as_str()), proto::v1::ChangePasswordRequest { user_id, old_password_hash: old_password_hash.to_string(), new_password_hash: new_password_hash.to_string(), keep_session_id: keep_session_id.to_string(), client_ip: client_ip.to_string(), }, ) .await } pub async fn get_mfa_status( &self, user_id: i64, ) -> Result { let request_id = crate::share::audit::current_request_id(); self.status_impl(proto::v1::GetMfaStatusRequest { user_id }) .await .map_err(|error| crate::share::auth_error::status(&error, Some(request_id.as_str()))) } pub async fn configure_totp( &self, user_id: i64, name: &str, client_ip: &str, ) -> Result { let request_id = crate::share::audit::current_request_id(); self.configure_totp_impl( proto::v1::ConfigureTotpRequest { user_id, name: name.to_string(), client_ip: client_ip.to_string(), }, Some(request_id.as_str()), ) .await .map_err(|error| crate::share::auth_error::status(&error, Some(request_id.as_str()))) } pub async fn enable_totp( &self, user_id: i64, code: &str, password_hash: &str, client_ip: &str, ) -> Result { let request_id = crate::share::audit::current_request_id(); self.enable_totp_impl( proto::v1::EnableTotpRequest { user_id, code: code.to_string(), password_hash: password_hash.to_string(), client_ip: client_ip.to_string(), }, Some(request_id.as_str()), ) .await .map_err(|error| crate::share::auth_error::status(&error, Some(request_id.as_str()))) } pub async fn disable_totp( &self, user_id: i64, code: &str, client_ip: &str, ) -> Result { let request_id = crate::share::audit::current_request_id(); self.disable_totp_impl( proto::v1::DisableTotpRequest { user_id, code: code.to_string(), client_ip: client_ip.to_string(), }, Some(request_id.as_str()), ) .await .map_err(|error| crate::share::auth_error::status(&error, Some(request_id.as_str()))) } pub async fn regenerate_recovery_codes( &self, user_id: i64, password_hash: &str, client_ip: &str, ) -> Result { let request_id = crate::share::audit::current_request_id(); self.regenerate_recovery_codes_impl( proto::v1::RegenerateRecoveryCodesRequest { user_id, password_hash: password_hash.to_string(), client_ip: client_ip.to_string(), }, Some(request_id.as_str()), ) .await .map_err(|error| crate::share::auth_error::status(&error, Some(request_id.as_str()))) } }