mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 02:58:59 +08:00
improve the readability of the function generate_api_key (#12552)
This commit is contained in:
parent
140965b738
commit
989fb11fd7
@ -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
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user