[+] API for unlinking

pull/14/head
Azalea 2024-02-22 18:20:54 -05:00
parent a001a45cc4
commit dd55e336e4
1 changed files with 15 additions and 0 deletions

View File

@ -74,6 +74,21 @@ class CardController(
SUCCESS SUCCESS
} }
@API("/unlink")
suspend fun unlink(@RP token: Str, @RP cardId: Str) = jwt.auth(token) { u ->
// Try to look up the card
val card = cardService.tryLookup(cardId) ?: (404 - "Card not found")
// If the card is not bound to the user
if (card.aquaUser != u) 400 - "Card not bound to user"
// Unbind the card
card.aquaUser = null
async { cardRepository.save(card) }
SUCCESS
}
} }
@Service @Service