core/protocol: split commands into separate files
All checks were successful
All checks were successful
This commit is contained in:
@@ -70,7 +70,7 @@ pub async fn create_users(
|
||||
.interact()?
|
||||
{
|
||||
let password = read_password_from_stdin_with_double_check(username)?;
|
||||
let message = Request::PasswdUser(username.to_owned(), password);
|
||||
let message = Request::PasswdUser((username.to_owned(), password));
|
||||
|
||||
if let Err(err) = server_connection.send(message).await {
|
||||
server_connection.close().await.ok();
|
||||
@@ -78,7 +78,7 @@ pub async fn create_users(
|
||||
}
|
||||
|
||||
match server_connection.next().await {
|
||||
Some(Ok(Response::PasswdUser(result))) => {
|
||||
Some(Ok(Response::SetUserPassword(result))) => {
|
||||
print_set_password_output_status(&result, username)
|
||||
}
|
||||
response => return erroneous_server_response(response),
|
||||
|
||||
@@ -73,7 +73,7 @@ pub async fn passwd_user(
|
||||
read_password_from_stdin_with_double_check(&args.username)?
|
||||
};
|
||||
|
||||
let message = Request::PasswdUser(args.username.to_owned(), password);
|
||||
let message = Request::PasswdUser((args.username.to_owned(), password));
|
||||
|
||||
if let Err(err) = server_connection.send(message).await {
|
||||
server_connection.close().await.ok();
|
||||
@@ -81,7 +81,7 @@ pub async fn passwd_user(
|
||||
}
|
||||
|
||||
let result = match server_connection.next().await {
|
||||
Some(Ok(Response::PasswdUser(result))) => result,
|
||||
Some(Ok(Response::SetUserPassword(result))) => result,
|
||||
response => return erroneous_server_response(response),
|
||||
};
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::core::protocol::{
|
||||
CreateDatabaseError, CreateUserError, DbOrUser, DropDatabaseError, DropUserError,
|
||||
GetDatabasesPrivilegeDataError, ListUsersError,
|
||||
CreateDatabaseError, CreateUserError, DropDatabaseError, DropUserError,
|
||||
GetDatabasesPrivilegeDataError, ListUsersError, request_validation::DbOrUser,
|
||||
};
|
||||
|
||||
pub fn name_validation_error_to_error_message(name: &str, db_or_user: DbOrUser) -> String {
|
||||
|
||||
@@ -235,10 +235,10 @@ async fn passwd_users(
|
||||
|
||||
for user in users {
|
||||
let password = read_password_from_stdin_with_double_check(&user.user)?;
|
||||
let message = Request::PasswdUser(user.user.to_owned(), password);
|
||||
let message = Request::PasswdUser((user.user.to_owned(), password));
|
||||
server_connection.send(message).await?;
|
||||
match server_connection.next().await {
|
||||
Some(Ok(Response::PasswdUser(result))) => match result {
|
||||
Some(Ok(Response::SetUserPassword(result))) => match result {
|
||||
Ok(()) => println!("Password updated for user '{}'.", &user.user),
|
||||
Err(_) => eprintln!(
|
||||
"{}: Failed to update password for user '{}'.",
|
||||
|
||||
Reference in New Issue
Block a user