Ability to unbind nesica card

This commit is contained in:
Ethan O'Brien
2026-09-02 10:09:24 -05:00
parent b92acb7a00
commit 59193d92f4
6 changed files with 352 additions and 304 deletions
+47
View File
@@ -634,6 +634,53 @@ pub fn bind_arcade_card(req: HttpRequest, body: String) -> HttpResponse {
}
}
// The signed-in account's linked cards, for the account page's list.
pub fn list_arcade_cards(req: HttpRequest) -> HttpResponse {
if crate::router::arcade::disabled() {
return HttpResponse::NotFound().finish();
}
let Some(uid) = session_uid(&req) else {
return error("Not logged in");
};
let resp = object!{
result: "OK",
data: {
card_ids: crate::database::arcade::cards_of_account(uid)
}
};
HttpResponse::Ok()
.insert_header(ContentType::json())
.body(jzon::stringify(resp))
}
// Unlink one of the signed-in account's own cards - the revocation a lost card
// needs, and the only way a card stops naming an account short of somebody
// else linking it.
pub fn unbind_arcade_card(req: HttpRequest, body: String) -> HttpResponse {
if crate::router::arcade::disabled() {
return HttpResponse::NotFound().finish();
}
let Some(uid) = session_uid(&req) else {
return error("Not logged in");
};
let body = jzon::parse(&body).unwrap_or(object!{});
let Some(card) = crate::router::arcade::valid_card_id(body["card_id"].as_str().unwrap_or("")) else {
return error("That is not a usable card id");
};
if !crate::database::arcade::remove_card_of(&card, uid) {
return error("That card is not linked to this account");
}
let resp = object!{
result: "OK",
data: {
card_id: card
}
};
HttpResponse::Ok()
.insert_header(ContentType::json())
.body(jzon::stringify(resp))
}
pub fn cheat(req: HttpRequest, _body: String) -> HttpResponse {
let token = get_login_token(&req);
if token.is_none() {