diff --git a/client/config.toml b/client/config.toml index cf791d2..a8462dd 100644 --- a/client/config.toml +++ b/client/config.toml @@ -74,7 +74,7 @@ move_left = [""] move_right = ["right"] suggestion_down = ["ctrl+n", "tab"] suggestion_up = ["ctrl+p", "shift+tab"] -trigger_autocomplete = ["left"] +trigger_autocomplete = ["tab"] [keybindings.command] exit_command_mode = ["ctrl+g", "esc"] diff --git a/server/src/auth/handlers/register.rs b/server/src/auth/handlers/register.rs index 63b6190..66a683f 100644 --- a/server/src/auth/handlers/register.rs +++ b/server/src/auth/handlers/register.rs @@ -11,6 +11,11 @@ pub async fn register( pool: &PgPool, payload: RegisterRequest, ) -> Result, Status> { + // Validate required fields + if payload.email.trim().is_empty() { + return Err(Status::invalid_argument("Email is required")); + } + // Validate passwords match if payload.password != payload.password_confirmation { return Err(Status::invalid_argument(AuthError::PasswordMismatch.to_string())); @@ -41,6 +46,15 @@ pub async fn register( if db_err.constraint() == Some("valid_roles") { return Status::invalid_argument(format!("Invalid role specified: '{}'", role_to_insert)); } + // Check for specific constraint violations + if let Some(constraint) = db_err.constraint() { + if constraint.contains("users_username_key") { + return Status::already_exists("Username already exists".to_string()); + } + if constraint.contains("users_email_key") { + return Status::already_exists("Email already exists".to_string()); + } + } } if e.to_string().contains("duplicate key") { Status::already_exists(AuthError::UserExists.to_string())