Skip to content

Commit

Permalink
fix: add signer check
Browse files Browse the repository at this point in the history
  • Loading branch information
ananas-block committed Sep 12, 2024
1 parent e2c2ab3 commit 47fcaa0
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions examples/name-service/programs/name-service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ pub mod name_service {
ctx: LightContext<'_, '_, '_, 'info, UpdateRecord<'info>>,
new_rdata: RData,
) -> Result<()> {
if ctx.light_accounts.record.owner != ctx.accounts.signer.key() {
return Err(CustomError::Unauthorized.into());
}
ctx.light_accounts.record.rdata = new_rdata;

Ok(())
Expand All @@ -40,6 +43,9 @@ pub mod name_service {
pub fn delete_record<'info>(
ctx: LightContext<'_, '_, '_, 'info, DeleteRecord<'info>>,
) -> Result<()> {
if ctx.light_accounts.record.owner != ctx.accounts.signer.key() {
return Err(CustomError::Unauthorized.into());
}
Ok(())
}
}
Expand Down

0 comments on commit 47fcaa0

Please sign in to comment.