mirror of
https://github.com/scottlamb/moonfire-nvr.git
synced 2025-12-08 08:42:41 -05:00
support disabling/enabling users by http api
This commit is contained in:
@@ -143,6 +143,9 @@ impl Service {
|
||||
}
|
||||
require_csrf_if_session(&caller, r.csrf)?;
|
||||
if let Some(mut precondition) = r.precondition {
|
||||
if matches!(precondition.disabled.take(), Some(d) if d != user.config.disabled) {
|
||||
bail_t!(FailedPrecondition, "disabled mismatch");
|
||||
}
|
||||
if matches!(precondition.username.take(), Some(n) if n != user.username) {
|
||||
bail_t!(FailedPrecondition, "username mismatch");
|
||||
}
|
||||
@@ -187,6 +190,9 @@ impl Service {
|
||||
if update != Default::default() && !caller.permissions.admin_users {
|
||||
bail_t!(Unauthenticated, "must have admin_users permission");
|
||||
}
|
||||
if let Some(d) = update.disabled.take() {
|
||||
change.config.disabled = d;
|
||||
}
|
||||
if let Some(n) = update.username.take() {
|
||||
change.username = n.to_string();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user