Skip to content
Snippets Groups Projects
Commit e4023024 authored by Cédric Moreau's avatar Cédric Moreau
Browse files

fix(#136): check memberships for issuer and receiver of a cert

parent 62e56e70
No related branches found
No related tags found
No related merge requests found
Pipeline #34247 waiting for manual action
...@@ -207,9 +207,8 @@ where ...@@ -207,9 +207,8 @@ where
// implement cert call checks // implement cert call checks
impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<IdtyIndex> impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<IdtyIndex>
for Pallet<T, I> for Pallet<T, I>
// TODO add the following where clause once checks can be done on pallet instance where
// where T: pallet_membership::Config<I>,
// T: pallet_membership::Config<I>,
{ {
// check the following: // check the following:
// - issuer has identity // - issuer has identity
...@@ -218,19 +217,6 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id ...@@ -218,19 +217,6 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id
// - receiver identity is confirmed or validated // - receiver identity is confirmed or validated
// - receiver has membership // - receiver has membership
// //
// /!\ do not check the following:
// - receiver has membership
// - issuer has membership
// this has the following consequences:
// - receiver can receive smith certification without having requested membership
// - issuer can issue cert even if he lost his membership
// (not renewed or passed below cert threshold and above again without claiming membership)
// this is counterintuitive behavior but not a big problem
//
// TODO to fix this strange behavior, we will have to make the tests
// (CheckCertAllowed and CheckMembershipCallAllowed) run on the relevant instance
// i.e. Cert for Wot, SmithCert for SmithWot...
// → see issue #136
fn check_cert_allowed(issuer: IdtyIndex, receiver: IdtyIndex) -> Result<(), DispatchError> { fn check_cert_allowed(issuer: IdtyIndex, receiver: IdtyIndex) -> Result<(), DispatchError> {
// issuer checks // issuer checks
// ensure issuer has validated identity // ensure issuer has validated identity
...@@ -242,12 +228,11 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id ...@@ -242,12 +228,11 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id
} else { } else {
return Err(Error::<T, I>::IdtyNotFound.into()); return Err(Error::<T, I>::IdtyNotFound.into());
} }
// issue #136 this has to be done on the correct instance of membership pallet // ensure issuer has membership
// // ensure issuer has membership if pallet_membership::Pallet::<T, I>::membership(issuer).is_none() {
// if pallet_membership::Pallet::<T, I>::membership(issuer).is_none() { // improvement: give reason why issuer can not emit cert (not member)
// // improvement: give reason why issuer can not emit cert (not member) return Err(Error::<T, I>::IssuerCanNotEmitCert.into());
// return Err(Error::<T, I>::IssuerCanNotEmitCert.into()); }
// }
// receiver checks // receiver checks
// ensure receiver has confirmed or validated identity // ensure receiver has confirmed or validated identity
...@@ -260,12 +245,12 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id ...@@ -260,12 +245,12 @@ impl<T: Config<I>, I: 'static> pallet_certification::traits::CheckCertAllowed<Id
return Err(Error::<T, I>::IdtyNotFound.into()); return Err(Error::<T, I>::IdtyNotFound.into());
} }
// issue #136 this has to be done on the correct instance of membership pallet // issue #136 this has to be done on the correct instance of membership pallet
// // ensure receiver has a membership or a pending membership // ensure receiver has a membership or a pending membership
// if pallet_membership::Pallet::<T, I>::pending_membership(issuer).is_none() if pallet_membership::Pallet::<T, I>::pending_membership(issuer).is_none()
// && pallet_membership::Pallet::<T, I>::membership(issuer).is_none() || pallet_membership::Pallet::<T, I>::membership(issuer).is_none()
// { {
// return Err(Error::<T, I>::CertToUndefined.into()); return Err(Error::<T, I>::CertToUndefined.into());
// } }
Ok(()) Ok(())
} }
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment