fix: reporter role save - add case-insensitive role mapping in create_user and update_user
Some checks failed
CI Pipeline / Rust Format Check (push) Successful in 5s
CI Pipeline / Clippy Lints (push) Successful in 52s
CI Pipeline / Rust Unit Tests (push) Successful in 1m10s
CI Pipeline / Security Audit (push) Failing after 4s
CI Pipeline / Frontend Lint & Type Check (push) Successful in 14s
CI Pipeline / Build .deb & Release (push) Has been skipped
Some checks failed
CI Pipeline / Rust Format Check (push) Successful in 5s
CI Pipeline / Clippy Lints (push) Successful in 52s
CI Pipeline / Rust Unit Tests (push) Successful in 1m10s
CI Pipeline / Security Audit (push) Failing after 4s
CI Pipeline / Frontend Lint & Type Check (push) Successful in 14s
CI Pipeline / Build .deb & Release (push) Has been skipped
This commit is contained in:
@ -96,10 +96,10 @@ async fn create_user(
|
||||
)
|
||||
})?;
|
||||
|
||||
let role = if req.role == "admin" {
|
||||
"admin"
|
||||
} else {
|
||||
"operator"
|
||||
let role = match req.role.to_lowercase().as_str() {
|
||||
"admin" => "admin",
|
||||
"reporter" => "reporter",
|
||||
_ => "operator",
|
||||
};
|
||||
|
||||
let id: Uuid = sqlx::query_scalar(
|
||||
@ -220,7 +220,11 @@ async fn update_user(
|
||||
let role_str = req
|
||||
.role
|
||||
.as_deref()
|
||||
.map(|r| if r == "admin" { "admin" } else { "operator" });
|
||||
.map(|r| match r.to_lowercase().as_str() {
|
||||
"admin" => "admin",
|
||||
"reporter" => "reporter",
|
||||
_ => "operator",
|
||||
});
|
||||
|
||||
let rows = sqlx::query(
|
||||
r#"UPDATE users SET
|
||||
|
||||
Reference in New Issue
Block a user