Skip to content
Snippets Groups Projects
Commit b8b406c5 authored by Hugo Trentesaux's avatar Hugo Trentesaux
Browse files

wip replace identity confirm check

parent 9e8a98cc
No related branches found
No related tags found
No related merge requests found
...@@ -136,16 +136,18 @@ where ...@@ -136,16 +136,18 @@ where
Ok(()) Ok(())
} }
} }
fn can_confirm_identity(idty_index: IdtyIndex) -> bool { fn check_confirm_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> {
if !T::IsSubWot::get() { if !T::IsSubWot::get() {
pallet_membership::Pallet::<T, I>::force_request_membership( match pallet_membership::Pallet::<T, I>::force_request_membership(
RawOrigin::Root.into(), RawOrigin::Root.into(),
idty_index, idty_index,
Default::default(), Default::default(),
) ) {
.is_ok() Ok(_) => Ok(()),
Err(e) => Err(e.error), // return error from inner function
}
} else { } else {
true Ok(())
} }
} }
fn can_validate_identity(idty_index: IdtyIndex) -> bool { fn can_validate_identity(idty_index: IdtyIndex) -> bool {
......
...@@ -340,9 +340,7 @@ pub mod pallet { ...@@ -340,9 +340,7 @@ pub mod pallet {
if <IdentitiesNames<T>>::contains_key(&idty_name) { if <IdentitiesNames<T>>::contains_key(&idty_name) {
return Err(Error::<T>::IdtyNameAlreadyExist.into()); return Err(Error::<T>::IdtyNameAlreadyExist.into());
} }
if !T::EnsureIdtyCallAllowed::can_confirm_identity(idty_index) { T::EnsureIdtyCallAllowed::check_confirm_identity(idty_index)?;
return Err(Error::<T>::NotAllowedToConfirmIdty.into());
}
// Apply phase // // Apply phase //
idty_value.status = IdtyStatus::ConfirmedByOwner; idty_value.status = IdtyStatus::ConfirmedByOwner;
...@@ -610,8 +608,6 @@ pub mod pallet { ...@@ -610,8 +608,6 @@ pub mod pallet {
InvalidRevocationSig, InvalidRevocationSig,
/// Identity not allowed to change address /// Identity not allowed to change address
NotAllowedToChangeIdtyAddress, NotAllowedToChangeIdtyAddress,
/// Not allowed to confirm identity
NotAllowedToConfirmIdty,
/// Not allowed to remove identity /// Not allowed to remove identity
NotAllowedToRemoveIdty, NotAllowedToRemoveIdty,
/// Not allowed to validate identity /// Not allowed to validate identity
......
...@@ -21,7 +21,7 @@ use sp_runtime::traits::Saturating; ...@@ -21,7 +21,7 @@ use sp_runtime::traits::Saturating;
pub trait EnsureIdtyCallAllowed<T: Config> { pub trait EnsureIdtyCallAllowed<T: Config> {
fn check_create_identity(creator: T::IdtyIndex) -> Result<(), DispatchError>; fn check_create_identity(creator: T::IdtyIndex) -> Result<(), DispatchError>;
fn can_confirm_identity(idty_index: T::IdtyIndex) -> bool; fn check_confirm_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError>;
fn can_validate_identity(idty_index: T::IdtyIndex) -> bool; fn can_validate_identity(idty_index: T::IdtyIndex) -> bool;
fn can_change_identity_address(idty_index: T::IdtyIndex) -> bool; fn can_change_identity_address(idty_index: T::IdtyIndex) -> bool;
fn can_remove_identity(idty_index: T::IdtyIndex) -> bool; fn can_remove_identity(idty_index: T::IdtyIndex) -> bool;
...@@ -34,9 +34,9 @@ impl<T: Config> EnsureIdtyCallAllowed<T> for Tuple { ...@@ -34,9 +34,9 @@ impl<T: Config> EnsureIdtyCallAllowed<T> for Tuple {
for_tuples!( #( Tuple::check_create_identity(creator)?; )* ); for_tuples!( #( Tuple::check_create_identity(creator)?; )* );
Ok(()) Ok(())
} }
fn can_confirm_identity(idty_index: T::IdtyIndex) -> bool { fn check_confirm_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError> {
for_tuples!( #( if !Tuple::can_confirm_identity(idty_index) { return false; } )* ); for_tuples!( #( Tuple::check_confirm_identity(idty_index)?; )* );
true Ok(())
} }
fn can_validate_identity(idty_index: T::IdtyIndex) -> bool { fn can_validate_identity(idty_index: T::IdtyIndex) -> bool {
for_tuples!( #( if !Tuple::can_validate_identity(idty_index) { return false; } )* ); for_tuples!( #( if !Tuple::can_validate_identity(idty_index) { return false; } )* );
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment