Skip to content

Commit

Permalink
entries: Restrict update operation only to Admin & Creator (#526)
Browse files Browse the repository at this point in the history
Signed-off-by: Shreevatsa N <[email protected]>
  • Loading branch information
vatsa287 authored Dec 2, 2024
1 parent 5f4d48d commit c06160f
Show file tree
Hide file tree
Showing 3 changed files with 726 additions and 7 deletions.
9 changes: 8 additions & 1 deletion pallets/entries/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,14 @@ pub mod pallet {
let mut entry = RegistryEntries::<T>::get(&registry_entry_id)
.ok_or(Error::<T>::RegistryEntryIdentifierDoesNotExist)?;

ensure!(entry.registry_id == registry_id, Error::<T>::UnauthorizedOperation);
ensure!(registry_id == entry.registry_id, Error::<T>::UnauthorizedOperation);

let is_admin =
pallet_registries::Pallet::<T>::is_admin_authorization(&authorization, &updater);

let is_creator = entry.creator == updater;

ensure!(is_admin || is_creator, Error::<T>::UnauthorizedOperation);

entry.digest = digest;

Expand Down
Loading

0 comments on commit c06160f

Please sign in to comment.