allow to change name

This commit is contained in:
2025-08-03 10:36:08 +02:00
parent ff19873f6a
commit 15c6223101
2 changed files with 49 additions and 3 deletions

View File

@@ -90,6 +90,30 @@ impl Backend {
let lang = language::language(&cookies, headers);
(cookies, Req { client, lang })
}
async fn set_client_name(&self, client: &Client, name: &str) -> Result<(), String> {
if name.len() > 25 {
return Err("Maximum 25 chars are allowed".into());
}
if name.len() < 3 {
return Err("Minimum of 3 chars needed".into());
}
match self {
Backend::Sqlite(db) => {
sqlx::query!(
"UPDATE client SET name = ? WHERE uuid = ?;",
name,
client.uuid
)
.execute(db)
.await
.unwrap();
}
}
Ok(())
}
}
#[tokio::main]