mirror of
https://git.mirrors.martin98.com/https://github.com/langgenius/dify.git
synced 2025-08-12 08:38:58 +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):
|
def generate_api_key(prefix, n):
|
||||||
while True:
|
while True:
|
||||||
result = prefix + generate_string(n)
|
result = prefix + generate_string(n)
|
||||||
while db.session.query(ApiToken).filter(ApiToken.token == result).count() > 0:
|
if db.session.query(ApiToken).filter(ApiToken.token == result).count() > 0:
|
||||||
result = prefix + generate_string(n)
|
continue
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user