Skip to content

Commit

Permalink
improve the readability of the function generate_api_key (#12552)
Browse files Browse the repository at this point in the history
  • Loading branch information
gakkiyomi authored Jan 9, 2025
1 parent 140965b commit 989fb11
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions api/models/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1405,9 +1405,8 @@ class ApiToken(db.Model): # type: ignore[name-defined]
def generate_api_key(prefix, n):
while True:
result = prefix + generate_string(n)
while db.session.query(ApiToken).filter(ApiToken.token == result).count() > 0:
result = prefix + generate_string(n)

if db.session.query(ApiToken).filter(ApiToken.token == result).count() > 0:
continue
return result


Expand Down

0 comments on commit 989fb11

Please sign in to comment.