|
@@ -209,6 +209,7 @@ async def register_old(request: Request):
|
|
|
user_obj = first(db.query('SELECT * FROM users where username ="'+str(user.username)+'"'))
|
|
|
if user_obj == None:
|
|
|
user_register(user)
|
|
|
+
|
|
|
user_obj = first(db.query('SELECT * FROM users where username ="'+str(request.username)+'"'))
|
|
|
veri_table = db['register_veri_code']
|
|
|
code = str(time.time()).replace('.','')
|
|
@@ -224,10 +225,14 @@ async def register_old(request: Request):
|
|
|
async def register(request: models.register_req):
|
|
|
db = dataset.connect('mysql://choozmo:pAssw0rd@db.ptt.cx:3306/AI_anchor?charset=utf8mb4')
|
|
|
user_obj = first(db.query('SELECT * FROM users where username ="'+str(request.username)+'"'))
|
|
|
-
|
|
|
+ then = datetime.now()
|
|
|
if user_obj == None:
|
|
|
if user_register(request):
|
|
|
- user_obj = first(db.query('SELECT * FROM users where username ="'+str(request.username)+'"'))
|
|
|
+ while user_obj == None :
|
|
|
+ user_obj = first(db.query('SELECT * FROM users where username ="'+str(request.username)+'"'))
|
|
|
+ duration = datetime.now() - then
|
|
|
+ if duration.total_seconds() > 10:
|
|
|
+ break
|
|
|
veri_table = db['register_veri_code']
|
|
|
code = str(time.time()).replace('.','')
|
|
|
veri_table.insert({'code':code,'user_id':user_obj['id']})
|