Skip to content

Commit

Permalink
fix: authority hint already exists check
Browse files Browse the repository at this point in the history
  • Loading branch information
jcmelati committed Aug 22, 2024
1 parent ce249ec commit 3f12def
Showing 1 changed file with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ class AuthorityHintService {
val account = Persistence.accountQueries.findByUsername(accountUsername).executeAsOneOrNull()
?: throw IllegalArgumentException(Constants.ACCOUNT_NOT_FOUND)

Persistence.authorityHintQueries.findByAccountIdAndIdentifier(account.id, identifier).executeAsOneOrNull()
?: throw IllegalArgumentException(Constants.AUTHORITY_HINT_ALREADY_EXISTS)
val authorityHintAlreadyExists =
Persistence.authorityHintQueries.findByAccountIdAndIdentifier(account.id, identifier).executeAsOneOrNull()

if (authorityHintAlreadyExists != null) {
throw IllegalArgumentException(Constants.AUTHORITY_HINT_ALREADY_EXISTS)
}

return Persistence.authorityHintQueries.create(account.id, identifier)
.executeAsOneOrNull()
Expand Down

0 comments on commit 3f12def

Please sign in to comment.