mirror of
https://github.com/MewoLab/AquaDX.git
synced 2026-02-13 12:07:27 +08:00
[+] Create new card if not exists
This commit is contained in:
@@ -48,7 +48,14 @@ class CardController(
|
|||||||
if (u.cards.size >= props.linkCardLimit) 400 - "Card limit reached"
|
if (u.cards.size >= props.linkCardLimit) 400 - "Card limit reached"
|
||||||
|
|
||||||
// Check if the card is already bound
|
// Check if the card is already bound
|
||||||
val card = cardService.tryLookup(cardId) ?: (404 - "Card not found")
|
val card = cardService.tryLookup(cardId)
|
||||||
|
if (card == null) {
|
||||||
|
// Create a new card
|
||||||
|
val newCard = cardService.registerByAccessCode(cardId)
|
||||||
|
cardRepository.save(newCard)
|
||||||
|
|
||||||
|
return SUCCESS
|
||||||
|
}
|
||||||
if (card.aquaUser != null) 400 - "Card already bound to another user (@${card.aquaUser?.username})"
|
if (card.aquaUser != null) 400 - "Card already bound to another user (@${card.aquaUser?.username})"
|
||||||
|
|
||||||
// Bind the card
|
// Bind the card
|
||||||
|
|||||||
Reference in New Issue
Block a user