From ee4061d10b27ba6b9b709a04f931f43942941e8e Mon Sep 17 00:00:00 2001 From: suti7yk5032 Date: Sat, 5 Oct 2024 09:35:49 +0900 Subject: [PATCH] =?UTF-8?q?=E5=AD=98=E5=9C=A8=E3=81=97=E3=81=AA=E3=81=84PC?= =?UTF-8?q?=E7=95=AA=E5=8F=B7=E3=81=AE=E5=A0=B4=E5=90=88=E3=81=AFINSERT?= =?UTF-8?q?=E3=81=A7=E3=83=AC=E3=82=B3=E3=83=BC=E3=83=89=E3=82=92=E4=BD=9C?= =?UTF-8?q?=E3=82=8B=E3=82=88=E3=81=86=E3=81=AB?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- dislocker_auth.py | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/dislocker_auth.py b/dislocker_auth.py index 0f1472e..04a47e3 100644 --- a/dislocker_auth.py +++ b/dislocker_auth.py @@ -307,18 +307,29 @@ class Auth(): cursor.execute("SELECT pc_uuid FROM pc_list WHERE pc_number = %s", (pc_number,)) pc_record = cursor.fetchall() 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) 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)) + 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() 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"} + 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: - print("停止処理中にエラーが発生しました。\nエラー内容") + print("PCの登録処理中にエラーが発生しました。\nエラー内容") print(str(error.__class__.__name__)) print(str(error.args)) print(str(error))