Ensure user/db prefix has a `_` behind it

This commit is contained in:
Oystein Kristoffer Tveit 2024-08-19 00:48:13 +02:00
parent cd0b2c3e6d
commit a6f00d4313
Signed by: oysteikt
GPG Key ID: 9F2F7D8250F35146
2 changed files with 3 additions and 1 deletions

View File

@ -76,6 +76,7 @@ impl OwnerValidationError {
indoc! {r#" indoc! {r#"
Invalid {} name prefix: '{}' does not match your username or any of your groups. Invalid {} name prefix: '{}' does not match your username or any of your groups.
Are you sure you are allowed to create {} names with this prefix? Are you sure you are allowed to create {} names with this prefix?
The format should be: <prefix>_<{} name>
Allowed prefixes: Allowed prefixes:
- {} - {}
@ -84,6 +85,7 @@ impl OwnerValidationError {
db_or_user.lowercased(), db_or_user.lowercased(),
name, name,
db_or_user.lowercased(), db_or_user.lowercased(),
db_or_user.lowercased(),
user.as_ref() user.as_ref()
.map(|u| u.username.clone()) .map(|u| u.username.clone())
.unwrap_or("???".to_string()), .unwrap_or("???".to_string()),

View File

@ -45,7 +45,7 @@ pub fn validate_ownership_by_prefixes(
if prefixes if prefixes
.iter() .iter()
.filter(|p| name.starts_with(*p)) .filter(|p| name.starts_with(&(p.to_string() + "_")))
.collect::<Vec<_>>() .collect::<Vec<_>>()
.is_empty() .is_empty()
{ {