Add bcrypt password hashing and user gender handling in yourchat2
Integrated bcrypt for password verification and updated user profile management to include gender and rights handling. Enhanced room access validation to consider gender restrictions and user rights. Updated database queries and structures to support new fields, ensuring compatibility with existing functionalities.
This commit is contained in:
20
src/main.rs
20
src/main.rs
@@ -232,15 +232,19 @@ async fn print_rooms_for_cli(
|
||||
if config.db_client.is_some() { "database" } else { "fallback" }
|
||||
);
|
||||
println!(
|
||||
"{:<30} {:<8} {:<8} {:<8} {:<10}",
|
||||
"name", "public", "min_age", "max_age", "password"
|
||||
"{:<24} {:<8} {:<8} {:<8} {:<8} {:<10} {:<8}",
|
||||
"name", "public", "gender", "min_age", "max_age", "password", "right_id"
|
||||
);
|
||||
println!("{}", "-".repeat(72));
|
||||
println!("{}", "-".repeat(92));
|
||||
for room in rooms {
|
||||
println!(
|
||||
"{:<30} {:<8} {:<8} {:<8} {:<10}",
|
||||
"{:<24} {:<8} {:<8} {:<8} {:<8} {:<10} {:<8}",
|
||||
room.name,
|
||||
if room.is_public { "yes" } else { "no" },
|
||||
room.gender_restriction_id
|
||||
.filter(|v| *v > 0)
|
||||
.map(|v| v.to_string())
|
||||
.unwrap_or_else(|| "-".to_string()),
|
||||
room.min_age
|
||||
.map(|v| v.to_string())
|
||||
.unwrap_or_else(|| "-".to_string()),
|
||||
@@ -252,6 +256,10 @@ async fn print_rooms_for_cli(
|
||||
} else {
|
||||
"set"
|
||||
},
|
||||
room.required_user_right_id
|
||||
.filter(|v| *v > 0)
|
||||
.map(|v| v.to_string())
|
||||
.unwrap_or_else(|| "-".to_string()),
|
||||
);
|
||||
}
|
||||
Ok(())
|
||||
@@ -283,8 +291,10 @@ where
|
||||
token: None,
|
||||
falukant_user_id: None,
|
||||
chat_user_id: None,
|
||||
gender_id: None,
|
||||
age: None,
|
||||
rights: HashSet::new(),
|
||||
right_type_ids: HashSet::new(),
|
||||
logged_in: false,
|
||||
tx: tx.clone(),
|
||||
},
|
||||
@@ -353,8 +363,10 @@ where
|
||||
token: None,
|
||||
falukant_user_id: None,
|
||||
chat_user_id: None,
|
||||
gender_id: None,
|
||||
age: None,
|
||||
rights: HashSet::new(),
|
||||
right_type_ids: HashSet::new(),
|
||||
logged_in: false,
|
||||
tx: tx.clone(),
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user