Skip to content

Commit

Permalink
change(fc-pallet-pass): ensure credential authentication is valid bef…
Browse files Browse the repository at this point in the history
…ore enabling feeless execution of `authenticate`
  • Loading branch information
pandres95 committed Oct 10, 2024
1 parent 53df95a commit dc31e36
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions pallets/pass/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,20 @@ pub mod pallet {
}

#[pallet::feeless_if(
|_: &OriginFor<T>, device_id: &DeviceId, _: &CredentialOf<T, I>, _: &Option<BlockNumberFor<T>>| -> bool {
if let Ok(account_id) = Pallet::<T, I>::account_id_for(credential.user_id()) {
Pallet::<T, I>::account_exists(&account_id)
} else {
false
}
|_: &OriginFor<T>, device_id: &DeviceId, credential: &CredentialOf<T, I>, _: &Option<BlockNumberFor<T>>| -> bool {
Pallet::<T, I>::account_id_for(credential.user_id())
.and_then(|account_id| {
ensure!(
Pallet::<T, I>::account_exists(&account_id),
Error::<T, I>::AccountNotFound
);
let device = Devices::<T, I>::get(&account_id, device_id)
.ok_or::<DispatchError>(Error::<T, I>::DeviceNotFound.into())?;
device
.verify_user(&credential)

Check warning on line 166 in pallets/pass/src/lib.rs

View workflow job for this annotation

GitHub Actions / clippy

this expression creates a reference which is immediately dereferenced by the compiler

warning: this expression creates a reference which is immediately dereferenced by the compiler --> pallets/pass/src/lib.rs:166:42 | 166 | ... .verify_user(&credential) | ^^^^^^^^^^^ help: change this to: `credential` | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_borrow = note: `#[warn(clippy::needless_borrow)]` on by default
.ok_or(Error::<T, I>::CredentialInvalid.into())
})
.is_ok()
}
)]
#[pallet::call_index(3)]
Expand Down

0 comments on commit dc31e36

Please sign in to comment.