存在しないPC番号の場合はINSERTでレコードを作るように
This commit is contained in:
parent
d643e6d1ba
commit
ee4061d10b
1 changed files with 15 additions and 4 deletions
|
@ -307,18 +307,29 @@ class Auth():
|
||||||
cursor.execute("SELECT pc_uuid FROM pc_list WHERE pc_number = %s", (pc_number,))
|
cursor.execute("SELECT pc_uuid FROM pc_list WHERE pc_number = %s", (pc_number,))
|
||||||
pc_record = cursor.fetchall()
|
pc_record = cursor.fetchall()
|
||||||
pc_record_uuid = pc_record[0][0]
|
pc_record_uuid = pc_record[0][0]
|
||||||
if pc_record_uuid == None:
|
cursor.execute("SELECT pc_number FROM pc_list WHERE pc_number = %s", (pc_number,))
|
||||||
|
pc_record = cursor.fetchall()
|
||||||
|
pc_record_number = pc_record[0][0]
|
||||||
|
if pc_record_number == None:
|
||||||
pc_token = self.token_generate(36)
|
pc_token = self.token_generate(36)
|
||||||
master_password = self.master_password_generate(16)
|
master_password = self.master_password_generate(16)
|
||||||
master_password_hash = self.hash_genarate(master_password)
|
master_password_hash = self.hash_genarate(master_password)
|
||||||
cursor.execute("UPDATE pc_list SET pc_uuid = %s, pc_token = %s, master_password = %s WHERE pc_number = %s", (pc_uuid, pc_token, master_password, pc_number))
|
cursor.execute("INSERT INTO pc_list (pc_number, pc_uuid, pc_token, master_password) VALUES (%s, %s, %s, %s)", (pc_number, pc_uuid, pc_token, master_password))
|
||||||
self.db.commit()
|
self.db.commit()
|
||||||
return {"result": 0, "about": "ok", "output_dict": {"pc_token": pc_token, "master_password": master_password, "master_password_hash": master_password_hash}}
|
return {"result": 0, "about": "ok", "output_dict": {"pc_token": pc_token, "master_password": master_password, "master_password_hash": master_password_hash}}
|
||||||
else:
|
else:
|
||||||
return {"result": 1, "about": "exist"}
|
if pc_record_uuid == None:
|
||||||
|
pc_token = self.token_generate(36)
|
||||||
|
master_password = self.master_password_generate(16)
|
||||||
|
master_password_hash = self.hash_genarate(master_password)
|
||||||
|
cursor.execute("UPDATE pc_list SET pc_uuid = %s, pc_token = %s, master_password = %s WHERE pc_number = %s", (pc_uuid, pc_token, master_password, pc_number))
|
||||||
|
self.db.commit()
|
||||||
|
return {"result": 0, "about": "ok", "output_dict": {"pc_token": pc_token, "master_password": master_password, "master_password_hash": master_password_hash}}
|
||||||
|
else:
|
||||||
|
return {"result": 1, "about": "exist"}
|
||||||
|
|
||||||
except Exception as error:
|
except Exception as error:
|
||||||
print("停止処理中にエラーが発生しました。\nエラー内容")
|
print("PCの登録処理中にエラーが発生しました。\nエラー内容")
|
||||||
print(str(error.__class__.__name__))
|
print(str(error.__class__.__name__))
|
||||||
print(str(error.args))
|
print(str(error.args))
|
||||||
print(str(error))
|
print(str(error))
|
||||||
|
|
Loading…
Reference in a new issue