Skip to content

Commit

Permalink
Merge pull request #96 from starknet-id/fix/coupon-can-only-be-used-once
Browse files Browse the repository at this point in the history
fix: coupon can only be used once
  • Loading branch information
Th0rgal authored Sep 6, 2024
2 parents 29f00aa + 40c761b commit 1c56cf9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/endpoints/campaigns/get_free_domain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,18 @@ pub async fn handler(
if let Ok(spent) = doc.get_bool("spent") {
if spent {
if let Ok(spent_by) = doc.get_str("spent_by") {
if (spent_by != to_hex(&query.addr)) {
if (spent_by == to_hex(&query.addr)) {
let r = doc.get_str("r").unwrap();
let s = doc.get_str("s").unwrap();
return (
StatusCode::OK,
Json(json!({
"r": r,
"s": s,
})),
)
.into_response();
} else {
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 {
Expand Down Expand Up @@ -111,6 +122,8 @@ pub async fn handler(
"$set" : {
"spent" : true,
"spent_by" : to_hex(&query.addr),
"r" : signature.r.to_string(),
"s" : signature.s.to_string(),
},
},
None,
Expand Down

0 comments on commit 1c56cf9

Please sign in to comment.