[+] Sanitize card id when creating card

This commit is contained in:
Azalea
2024-02-22 17:29:13 -05:00
parent 2d1cad870b
commit 6a16e5534d
2 changed files with 39 additions and 6 deletions

View File

@@ -47,15 +47,21 @@ class CardController(
// Check if the user's card limit is reached
if (u.cards.size >= props.linkCardLimit) 400 - "Card limit reached"
// Check if the card is already bound
// Try to look up the card
val card = cardService.tryLookup(cardId)
// If no card is found, create a new card
if (card == null) {
// Ensure the format of the card ID is correct
val id = cardService.sanitizeCardId(cardId)
// Create a new card
val newCard = cardService.registerByAccessCode(cardId)
cardRepository.save(newCard)
cardService.registerByAccessCode(id, u)
return SUCCESS
}
// If card is already bound
if (card.aquaUser != null) 400 - "Card already bound to another user"
// Bind the card