Skip to content

Commit

Permalink
fix: coupon already used
Browse files Browse the repository at this point in the history
  • Loading branch information
Marchand-Nicolas committed Sep 5, 2024
1 parent a408464 commit 5ec4fd0
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/endpoints/campaigns/get_free_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,16 @@ pub async fn handler(
Ok(Some(doc)) => {
if let Ok(spent) = doc.get_bool("spent") {
if spent {
return get_error("Coupon code already used".to_string());
if let Ok(spent_by) = doc.get_str("spent_by") {
if (spent_by != to_hex(&query.addr)) {
return get_error(format!("Coupon code already used by {}\nIf you own this account, this means you have already used this coupon code with the other account. Please switch to it.", spent_by));
}
} else {
return get_error("Coupon code already used by someone else".to_string());
}
}
} else {
println!("Error while verifying coupon code spent status and user address");
return get_error("Error while verifying coupon code availability".to_string());
}

Expand Down Expand Up @@ -103,6 +110,7 @@ pub async fn handler(
doc! {
"$set" : {
"spent" : true,
"spent_by" : to_hex(&query.addr),
},
},
None,
Expand Down

0 comments on commit 5ec4fd0

Please sign in to comment.