mirror of https://github.com/JohnHammond/CTFd.git
Don't reuse used oauth_ids in populate.py (#1062)
* Fix `populate.py` from using an `oauth_id` twice.selenium-screenshot-testing
parent
1c9e36fa8f
commit
bf05b30d56
14
populate.py
14
populate.py
|
@ -279,6 +279,7 @@ if __name__ == '__main__':
|
|||
# Generating Teams
|
||||
print("GENERATING TEAMS")
|
||||
used = []
|
||||
used_oauth_ids = []
|
||||
count = 0
|
||||
while count < TEAM_AMOUNT:
|
||||
name = gen_team_name()
|
||||
|
@ -291,7 +292,11 @@ if __name__ == '__main__':
|
|||
if random_chance():
|
||||
team.affiliation = gen_affiliation()
|
||||
if random_chance():
|
||||
team.oauth_id = random.randint(1, 1000)
|
||||
oauth_id = random.randint(1, 1000)
|
||||
while oauth_id in used_oauth_ids:
|
||||
oauth_id = random.randint(1, 1000)
|
||||
used_oauth_ids.append(oauth_id)
|
||||
team.oauth_id = oauth_id
|
||||
db.session.add(team)
|
||||
count += 1
|
||||
|
||||
|
@ -301,6 +306,7 @@ if __name__ == '__main__':
|
|||
# Generating Users
|
||||
print("GENERATING USERS")
|
||||
used = []
|
||||
used_oauth_ids = []
|
||||
count = 0
|
||||
while count < USER_AMOUNT:
|
||||
name = gen_name()
|
||||
|
@ -316,7 +322,11 @@ if __name__ == '__main__':
|
|||
if random_chance():
|
||||
user.affiliation = gen_affiliation()
|
||||
if random_chance():
|
||||
user.oauth_id = random.randint(1, 1000)
|
||||
oauth_id = random.randint(1, 1000)
|
||||
while oauth_id in used_oauth_ids:
|
||||
oauth_id = random.randint(1, 1000)
|
||||
used_oauth_ids.append(oauth_id)
|
||||
user.oauth_id = oauth_id
|
||||
if mode == 'teams':
|
||||
user.team_id = random.randint(1, TEAM_AMOUNT)
|
||||
db.session.add(user)
|
||||
|
|
Loading…
Reference in New Issue