mirror of
https://git.ethanthesleepy.one/ethanaobrien/ew
synced 2026-10-12 01:24:27 +08:00
Ability to unbind nesica card
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user