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