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

wip replace identity validation check

parent b8b406c5
No related branches found
No related tags found
No related merge requests found
......@@ -150,18 +150,20 @@ where
Ok(())
}
}
fn can_validate_identity(idty_index: IdtyIndex) -> bool {
fn check_validate_identity(idty_index: IdtyIndex) -> Result<(), DispatchError> {
if !T::IsSubWot::get() {
// TODO replace this code by the commented one for distance feature
/*let idty_cert_meta = pallet_certification::Pallet::<T, I>::idty_cert_meta(idty_index);
idty_cert_meta.received_count >= T::MinCertForMembership::get() as u32*/
pallet_membership::Pallet::<T, I>::claim_membership(
match pallet_membership::Pallet::<T, I>::claim_membership(
RawOrigin::Root.into(),
Some(idty_index),
)
.is_ok()
) {
Ok(_) => Ok(()),
Err(e) => Err(e.error),
}
} else {
true
Ok(())
}
}
fn can_change_identity_address(idty_index: IdtyIndex) -> bool {
......
......@@ -369,9 +369,7 @@ pub mod pallet {
match idty_value.status {
IdtyStatus::Created => return Err(Error::<T>::IdtyNotConfirmedByOwner.into()),
IdtyStatus::ConfirmedByOwner => {
if !T::EnsureIdtyCallAllowed::can_validate_identity(idty_index) {
return Err(Error::<T>::NotAllowedToValidateIdty.into());
}
T::EnsureIdtyCallAllowed::check_validate_identity(idty_index)?;
}
IdtyStatus::Validated => return Err(Error::<T>::IdtyAlreadyValidated.into()),
}
......@@ -610,8 +608,6 @@ pub mod pallet {
NotAllowedToChangeIdtyAddress,
/// Not allowed to remove identity
NotAllowedToRemoveIdty,
/// Not allowed to validate identity
NotAllowedToValidateIdty,
/// Identity creation period is not respected
NotRespectIdtyCreationPeriod,
/// Not the same identity name
......
......@@ -22,7 +22,7 @@ use sp_runtime::traits::Saturating;
pub trait EnsureIdtyCallAllowed<T: Config> {
fn check_create_identity(creator: T::IdtyIndex) -> Result<(), DispatchError>;
fn check_confirm_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError>;
fn can_validate_identity(idty_index: T::IdtyIndex) -> bool;
fn check_validate_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError>;
fn can_change_identity_address(idty_index: T::IdtyIndex) -> bool;
fn can_remove_identity(idty_index: T::IdtyIndex) -> bool;
}
......@@ -38,9 +38,9 @@ impl<T: Config> EnsureIdtyCallAllowed<T> for Tuple {
for_tuples!( #( Tuple::check_confirm_identity(idty_index)?; )* );
Ok(())
}
fn can_validate_identity(idty_index: T::IdtyIndex) -> bool {
for_tuples!( #( if !Tuple::can_validate_identity(idty_index) { return false; } )* );
true
fn check_validate_identity(idty_index: T::IdtyIndex) -> Result<(), DispatchError> {
for_tuples!( #( Tuple::check_validate_identity(idty_index)?; )* );
Ok(())
}
fn can_change_identity_address(idty_index: T::IdtyIndex) -> bool {
for_tuples!( #( if !Tuple::can_change_identity_address(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